Page 1 of 5 12345>
Topic Options
#186913 - 2008-04-15 05:39 AM KiXgolf 2008 Schmankerl: Check Scanning
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Commemmorating my 24th post:

=============
The Challenge: Check Scanning
=============

A bank wishes to use optical character recognition (OCR) to read account numbers from checks. These particular account numbers are written using seven-segment digits. Some image-processing software recognizes horizontal and vertical segments on a scanned check, and converts them to ASCII bars ‘|’ and underscores ‘_’. When correctly printed, the ten digits look like this:

 Code:
...  ._.  ._.  ...  ._.  ._.  ._.  ._.  ._.  ._.
..|  ._|  ._|  |_|  |_.  |_.  ..|  |_|  |_|  |.|
..|  |_.  ._|  ..|  ._|  |_|  ..|  |_|  ._|  |_|


A bank account has a 9-digit account number. Not all 9-digit numbers are valid; for purposes of error detection and correction, a correct account number d9d8 · · · d1 satisfies the following checksum condition:
(d1 + 2d2 + 3d3 + . . . + 9d9) mod 11 = 0.
Unfortunately, the scanner sometimes makes mistakes: some line segments may be missing. Your task is to write a program that deduces the original number, assuming that:
  • when the input represents a valid account number, it is the original number
  • at most one digit is garbled
  • the scanned image contains no extra segments

The scanner outputs ASCII bars (‘|’ and ‘_’) for segments it sees, and periods for spaces that contain no segment. For example, the following input:
 Code:
...._.._....._.._.._.._.._.
..|._|._||_||_.|_...||_||_|
..|._.._|..|._||_|..||_|._|

used to be 123456789. Making the second digit into a ‘3’ instead of ‘2’ would violate the checksum condition. Other modifications (such as changing ‘5’ into ‘6’) would violate the “only one garbled digit” criterion.

The input consists of a sequence of account numbers rendered in ASCII. Each account number takes up three lines in an array, and each digit takes up three columns, giving 27 characters per line. There are no blank lines or extra blank columns anywhere. For each test case, the output contains one line giving the nine digits if the correct account number can be determined, the string “failure” if no solutions were found and “ambiguous” if more than one solution was found.

A download is available at http://s91376351.onlinehome.us/kixtart/kixgolf_cs.zip

=============
Inputs & Outputs
=============


Input: One array containing a single check number in ASCII

Output: The check number or either of the two words "failure" and "ambiguous"

=======
Scoring
=======


The solution must pass all tests in order for it's KiXgolf Score to be considered.

When posting KiXtart Golf Scores, please include the KIXGOLF_*.TXT file that is created in the script directory. It contains some basic information about the computer that the script is run on and the resulting scores.

============
Test program
============


Test cases are provided to help screen entries and to provide the Golf Score.
Any script that passes the test cases can be submitted. If you are surprised that your solution passed the test cases, please submit it anyway! That will help me identify bugs in the test program.

================================================================
KiXtart GOLF - How To Play
================================================================


Most importantly, anybody can play, no age restrictions, no penalties, no handicap!

The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.

Example: How many positive elements are in array $a?

Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9]

One approach:
 Code:
for $b=0 to ubound($a)
  if $a[$b]>0
    $c=$c+1
  endif
next

for a score of 45.

Another solution is:
 Code:
DO
  $b=$b+1
  if $a[$b]>0
    $c=$c+1
  endif
UNTIL $b>(UBOUND($a)+1)

for a score of 53.

Better approach: Code sample 1

================================================================
KiXtart GOLF - The Rules
================================================================


1) The goal of KiXtart Golf is to score the lowest strokes.
2) Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count or spaces in between the '=' sign when assigning variables, e.g. '$a = $b' scores 5.
3) Code can be constructed any way you like, as long as it does not generate syntax or other errors when running the script in KiXtart.
4) The final solution MUST pass all test scripts that are part of the KiXtart golf challenge.
7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player.
8) During the public coding phase, code should be posted, reused, and borrowed from other players.
9) The test script contains the official KiXgolf scoring engine
10) Only the person posting a particular score will be recognized for the score, unless the KiXtart Golf Challenge organizer or another delegate posts code on behalf of a player
11) KiXtart Golf (a.k.a KiXgolf) codes must be written inside the KiXgolf UDF collection tags, ';!' and ';!;!' and must be eclosed by the FUNCTION commands
12) Parameter names of the UDF's can be changed and additional optional parameters can be added.
13) Additional helper UDFs can be written as long as they reside inside the ';!' and ';!;!' tags.
14) The use of '$' as a variable is allowed.
15) The UDF layout is up to coder.
16) The UDF is expected to finish in a reasonable time, that is, on modern computers inside 1 hour timeframe.
17) You can submit scores as often as you want.
18) If you reach leading score, you are obligated to post your score immediately so others can try to compete with you.
19) The UDF may only use the KiXtart/KiXforms commands/functions/macros, no other code fragments are allowed.
20) Calls to COM components that are part of a standard default Windows installation are allowed.
21) The use of the KiXforms DLL is also permitted as the KiXforms DLL can now be considered an integral part of KiXtart scripting.
22) Calls to other executables, as long as they are part of a standard default Windows installation are allowed.
23) The UDF should be self-contained (except for any I/O mentioned in the challenge). In particular, you may not do things like fetching extra data from a remote site or file.
24) You may assume ASCII as character set.
25) You may use block comments as the KiXgolf Scoring Engine now supports block comments.
26) You are allowed to only use publicly available versions of KiXtart and KiXforms, private builds or alpha builds are NOT allowed.
27) Your submitted score must include the result print of the KiXgolf test-engine.
28) The SETOPTION() parameters in the KiXgolf script may not be modified and will govern the script behavior. SETOPTION() parameters may change depending on the particular needs of the KiXgolf challenge.
29) Tokenizing the UDF, script, or portions thereof is not allowed.
30) If something is not explicitly denied by the rules, it's allowed.
31) If Confusion arises, arranger of the KiXgolf round has the final say.
32) Additional test cases can be added during the private round by submitting a proposal for a new test case to the BBS. The proposed test case becomes official once it has been added to the existing test cases and the KiXgolf package has been reposted for download. If new test cases are added within 12 hours of private round end the private round will extend by an additional 24 hours. The public round will then start one day later and also end one day later. Not additional test cases will be added during the public round.


================================================================
KiXtart GOLF - The Duration of the Competition
================================================================


1) Private coding phase: From date/time of posting the tournament challenge to April 19, 10pm EST (BBS+6 time)

2) Public coding phase: From April 19, 10pm EST (BBS+6 time) to April 25, 10pm EST (BBS+6 time)

3) Final results: April 26, 11pm EST (BBS+6 time)

You will need the complete package from http://s91376351.onlinehome.us/kixtart/kixgolf_cs.zip.


Edited by Sealeopard (2008-04-17 03:59 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#186915 - 2008-04-15 06:08 AM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Sealeopard]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
24th post?
Top
#186916 - 2008-04-15 08:24 AM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Allen]
RemcovC Offline
Starting to like KiXtart
*****

Registered: 2006-09-13
Posts: 174
Loc: Holland
Who's counting... we can golf again \:\)
_________________________
It's better to have scripted and died, then to never have scripted at all

Top
#186917 - 2008-04-15 08:35 AM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: RemcovC]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
whoah, an unannounced golf-round? Hmmm... let's see if I can postpone some other less important stuff in my agenda ;\)
_________________________
The Code is out there

Top
#186933 - 2008-04-15 09:11 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Sealeopard]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
A Schmankerl?
Nice to be back on the green!
_________________________



Top
#186935 - 2008-04-15 09:54 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Jochen]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
For those that do not speak German.

 Code:
Schmankerl {n} [bayr.] [österr.] 
	delicacy
	tidbit [Am.]
	titbit [Br.]
	tasty tidbit [Am.] 

Schmankerl {n} [fig.] [bayr.] [österr.] 
	treat
	gem [fig.] 
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#186937 - 2008-04-15 10:36 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Mart]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Quote:

(such as changing ‘5’ into ‘6’)

sorry?
changing 5 to 6 is only one change. just like changing "9" to "8"

Jens dear, please clarify.
_________________________
!

download KiXnet

Top
#186938 - 2008-04-15 10:45 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn this is kinda "stupid"
thinking about the possibilities, the code will became enermous to count for all.

think I will once again start in the public round.
_________________________
!

download KiXnet

Top
#186940 - 2008-04-15 11:08 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Lonkero]
RemcovC Offline
Starting to like KiXtart
*****

Registered: 2006-09-13
Posts: 174
Loc: Holland
Ok.... after a couple of hours... I finally got a working code, now its time to shave \:\)

 Code:

Your solution passed all tests

KiXtart
KiXtart Version  = 4.60
KiXGolf Script   = kixgolf_cs.kix

KiXGolf Scoring Engine
Scoring Engine   = 3.3

KiXtart Golf Score
Tournament       = Check Scanning
Processing Start = 2008/04/15 23:06:51.381
Processing End   = 2008/04/15 23:06:51.403
Duration         = 0000/00/00 00:00:00.022
KiXGolf Score    = 980
 
Thank you for participating in KiXtart Golf!
_________________________
It's better to have scripted and died, then to never have scripted at all

Top
#186941 - 2008-04-15 11:54 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: RemcovC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Quote:

a correct account number d9d8 · · · d1 satisfies the following checksum condition:
(d1 + 2d2 + 3d3 + . . . + 9d9) mod 11 = 0.


does this mean that d9 is the first digit or the last?

where is that Jens when you need him!?!
_________________________
!

download KiXnet

Top
#186942 - 2008-04-15 11:58 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
for test number 4, also this seems to be possible:
878899898

just an example to show that the parameters of this golf round just don't add up.
_________________________
!

download KiXnet

Top
#186947 - 2008-04-16 02:53 AM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Lonkero]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
The 24th post reference was a way of announcing having reached 11000 posts, it being the binary equivalent of 24.

Regarding Jooels comment on the example: The correct number is 123456789. Therefore one would have to change the second digit to a "2". Any other changes (in addition to the changes to "2"), e.g.changing the 5 to a 6, would violate the “only one garbled digit” criterion.

Regarding the positons of the digits, for example check number 123456789 has a checksum of 0:
 Code:
1  2  3  4  5  6  7  8  9
d9 d8 d7 d6 d5 d4 d3 d2 d1


Hope that clears things up.
_________________________
There are two types of vessels, submarines and targets.

Top
#186952 - 2008-04-16 08:50 AM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Sealeopard]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Ok, I'm confused

If I change the last 8 in test-case 3 to a 0 it's a valid result...

If I change the last 8 in test-case 4 to a 1 (instead of the 1 into a 7) it's also a valid result...

I didn't try any more possibilities but I'm sure that there are more. Doesn't that mean that test 2, 3 & 4 are all ambiguous?


Congrats on the 11K btw! \:D


Edited by DrillSergeant (2008-04-16 08:51 AM)
_________________________
The Code is out there

Top
#186953 - 2008-04-16 09:02 AM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: DrillSergeant]
RemcovC Offline
Starting to like KiXtart
*****

Registered: 2006-09-13
Posts: 174
Loc: Holland
You are only allowed to add _ and | not to remove them

 Quote:

Unfortunately, the scanner sometimes makes mistakes: some line segments may be missing.
_________________________
It's better to have scripted and died, then to never have scripted at all

Top
#186959 - 2008-04-16 12:07 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: RemcovC]
RemcovC Offline
Starting to like KiXtart
*****

Registered: 2006-09-13
Posts: 174
Loc: Holland
 Quote:
1) Private coding phase: From date/time of posting the tournament challenge to April 17, 10pm EST (BBS+6 time)

2) Public coding phase: From April 17, 10pm EST (BBS+6 time) to April 20, 10pm EST (BBS+6 time)

3) Final results: April 21, 11pm EST (BBS+6 time)


Is it just me, or is the coding time (privat and public) really shortened ?
I was hoping that I could work on my code some more next weekend. Maybe because the tournament wasn't announced the time can be extended a little please ?
_________________________
It's better to have scripted and died, then to never have scripted at all

Top
#186960 - 2008-04-16 02:01 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Jens you didn't reply to this "obvious" flaw in the logic:
 Originally Posted By: Lonkero
for test number 4, also this seems to be possible:
878899898

just an example to show that the parameters of this golf round just don't add up.


meaning, there are multiple correct answers with the given parameters.
_________________________
!

download KiXnet

Top
#186962 - 2008-04-16 02:26 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Lonkero]
RemcovC Offline
Starting to like KiXtart
*****

Registered: 2006-09-13
Posts: 174
Loc: Holland
This is not an flaw...

 Quote:
Unfortunately, the scanner sometimes makes mistakes: some line segments may be missing.

 Quote:
at most one digit is garbled

 Quote:
the scanned image contains no extra segments


There is no way you get 878899898 as result from test 4 because you break 2 rules. you have to unscramble more then 1 digit and you have to remove segments from a digit.


Edited by RemcovC (2008-04-16 02:27 PM)
_________________________
It's better to have scripted and died, then to never have scripted at all

Top
#186965 - 2008-04-16 04:24 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: RemcovC]
RemcovC Offline
Starting to like KiXtart
*****

Registered: 2006-09-13
Posts: 174
Loc: Holland
ok scripting time again \:\)

Removed some debugging code (stupid me) an rearranged the vars which results in:

 Code:

Your solution passed all tests

KiXtart
KiXtart Version  = 4.60
KiXGolf Script   = kixgolf_cs.kix

KiXGolf Scoring Engine
Scoring Engine   = 3.3

KiXtart Golf Score
Tournament       = Check Scanning
Processing Start = 2008/04/16 16:23:54.218
Processing End   = 2008/04/16 16:23:54.234
Duration         = 0000/00/00 00:00:00.015
KiXGolf Score    = 841
 
Thank you for participating in KiXtart Golf!
_________________________
It's better to have scripted and died, then to never have scripted at all

Top
#186967 - 2008-04-16 05:08 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: RemcovC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, so I misunderstood.
I thought it was like each digit could have one bar wrong and segments could be removed as well as added.
_________________________
!

download KiXnet

Top
#186968 - 2008-04-16 05:12 PM Re: KiXgolf 2008 Schmankerl: Check Scanning [Re: Mart]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mart...
think that dr. house quote is wrong.
should be "there is me though, if chumble(?) it up"
not sure about the spelling...
_________________________
!

download KiXnet

Top
Page 1 of 5 12345>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 898 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.155 seconds in which 0.084 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org