TSQL Challenge 21 – Reading, recognizing and processing graphical representation of digits. – TSQL Challenges

Posted by: Lava Kafle

Here is a challenge that takes you away from those repetitive boring type of queries that you write over and over again, several times a day. All of us, the database people, are familiar with thinking in set based manner as well as row by row style. Here is something that is very interesting where you might need to process records in a ‘three-line-at-a-time’ fashion.

For the purpose of this challenge, imagine that you are working for a bank which just decided to scan all the banking documents. Assume that they have an old fashioned scanner which scans the documents and produces a text file with the customer number. So far so good. Well, not really! Unfortunately the scanner produces a graphical representation of the customer number using three lines of symbols: space, unerscores and pipe characters. Here is an example of the output produced by the scanner.

1. _  _     _  _  _  _  _
2.| _| _||_||_ |_   ||_||_|
3.||_  _|  | _||_|  ||_| _|

Here are the rules to keep in mind while reading and recognizing the output generated by the scanner.

  • Each digit is represented using 9 cells (3×3)
  • Only spaces, underscores and pipe characters are used
  • The number of digits in each account number may vary.
  • The Scanner is not 100% reliable and it might produce some digits that are invalid

The Challenge

Your job is to read the output produced by the scanner and identify the the customer number represented by each image. Remember that the scanner is not very reliable and it might produce invalid digit representations. For each digit that is not valid, set the value to ‘X’

TSQL Challenge 21 – Reading, recognizing and processing graphical representation of digits. – TSQL Challenges.

TSQL Challenge 21 – Reading, recognizing and processing graphical representation of digits. – TSQL Challenges was last modified: May 18th, 2010 by Lava Kafle

Blog Comments

Post Your Comments:

Your email address will not be published. Required fields are marked *