Page 1 of 9 12345>Last »
Topic Options
#199193 - 2010-08-01 05:56 PM KixGolf - Luhn's Mod
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
=============
The Challenge - Luhn's Mod
=============


In 1954, Hans Luhn of IBM proposed an algorithm to be used as a validity criterion for a given set of numbers. Almost all credit card numbers are generated following this validity criterion…also called as the Luhn check or the Mod 10 check. It goes without saying that the Luhn check is also used to verify a given existing card number. If a credit card number does not satisfy this check, it is not a valid number.

Out of the 16 numbers on a typical credit card, the set of first 6 digits is known as the issuer identifier number, and the last digit is known as the “check digit” which is generated in such a way as to satisfy the Luhn or Mod 10 check.

For a 16 digit credit card number, the Luhn check can be described as follows:

1. Starting with the check digit, double the value of every second digit (never double the check digit). For example, in a 16 digit credit card number, double the 15th, 13th, 11th, 9th…digits (digits in odd places). In all, you will need to double eight digits.

2. If doubling of a number results in a two digit number, add up the digits to get a single digit number. This will result in eight new single digit numbers.
3. Now, replace the digits in the odd places (in the original credit card number) with these new single digit numbers to get a new 16 digit number.
4. Add up all the digits in this new number. If the final total is perfectly divisible by 10, then the credit card number is valid (Luhn check is satisfied), else it is invalid.

Example:
 Code:
                           
4 5 5 2 7 2 0 4 1 2 3 4 5 6 7 8 <-starting card number, last digit is the check digit
8  10  14   0   2   6  10  14   <-doubled value of every second digit starting from right
8   1   5   0   2   6   1   5   <-if the number > 10 add up the digits to get a single digit number
8 5 1 2 5 2 0 4 2 2 6 4 1 6 5 8 <-This is the new number.  Add up the digits. 
=61                             <-61 is not perfectly divisible by 10, and fails the test.

There are many brands of credit cards, but the following are the only brands your company will accept.
 Code:
Brand        Number of Digits 	Example of a Valid Card 
--------------------------------------------------------
AmKixpress   15			373633498141735
Kixa         16			4929930484621725
MasterScript 16			5380933823620159
Dectohex     16			6011691716199864

For the purposes of this tournament, and to destinguish between brands, each company always starts it's cards with the same first digit. For example Kixa always starts with a "4".

AmKixpress only has 15 digits, however all the others have 16 digits.

The Expiration Date and CCV Number are not part of this challenge.

** These are NOT valid credit card numbers. You can't buy anything with these. They are random numbers that happen to conform to the algorithm. **

*-->A download is available at http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=208

=============
Specification
=============


Determine whether the numbers provided in the input:
1) Passes Luhn's Check
2) Has the proper number of digits for it's issuer
3) Is a card your company accepts

=============
Inputs
=============

The input consists of a string of numbers. (The limits within Kixtart and such a large number requries that the input be a string.)

=============
Outputs
=============


0, 3, 4, 5 , or 6.

0 = Fails any test
3 = Valid AmKixPress
4 = Valid Kixa
5 = Valid MasterScript
6 = Valid Dectohex

=================================================================
Notes
===========================================================+====

- The scoring engine is based on older engine, so there may be something like block comments that are not supported.
- The scoring engine has added code to help diagnose which cases are failing. To see test case resutls: kix32 kixgolf_lm $verbose=1
- The scoring engine expects your (primary) function to be named a().


=======
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 ';!;!'
12) Parameter names of the UDF's can be changed and additional optional parameters can be added.
13) Additional helper UDFs and code 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 at any time during the KiXgolf round. The code is expected to pass based on the rules. The test cases may not include tests for all rules and exceptions. Test cases that are added during the public round will not alter the results of the private round.


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


1) Private coding phase: 2010-08-01 to 2010-08-08 (Official Count down clock will determine end time)

2) Public coding phase: 2010-08-08 to 2010-08-15

3) Final results: 2010-08-16


*--> You will need the complete package from http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=208.


Attachments
kixgolf_lm.zip (544 downloads)
Description:



Top
#199194 - 2010-08-01 05:57 PM Re: KixGolf - Luhn's Mod [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Count down clock removed.

Edited by Allen (2010-08-15 06:52 PM)

Top
#199207 - 2010-08-02 07:04 AM Re: KixGolf - Luhn's Mod [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hey Al,

your dl lnk is 404 \:\(
_________________________



Top
#199210 - 2010-08-02 01:19 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
I say it's a multi-stroke penalty for Allen for holding a tournament on a closed course! ;\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#199211 - 2010-08-02 02:02 PM Re: KixGolf - Luhn's Mod [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany


_________________________



Top
#199212 - 2010-08-02 02:45 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Sorry... I know it was working...

I'll just put it here... hang on...

Top
#199213 - 2010-08-02 02:54 PM Re: KixGolf - Luhn's Mod [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Okay... links updated. The first link was directly to the file on SkyDrive... I guess they update the links or something. \:\(
Top
#199214 - 2010-08-02 04:18 PM Re: KixGolf - Luhn's Mod [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
It works!
 Code:
KiXGolf Scoring Engine
Scoring Engine   = 3.0.3

KiXtart Golf Score
Tournament       = KiXtart Golf: Luhn's Mod
Processing Start = 2010/08/02 10:15:55.842
Processing End   = 2010/08/02 10:15:55.873
Duration         = 0000/00/00 00:00:00.031
# Tests Run      = 50
# Tests Passed   = 50
# Tests Failed   = 0
Result           = passed
KiXGolf Score    = 220
Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#199215 - 2010-08-02 04:29 PM Re: KixGolf - Luhn's Mod [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
What is your score Glenn?
_________________________



Top
#199216 - 2010-08-02 04:39 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
It was several hundred, but I have a bunch of debug statements in it..

I'll post the full output with the score with I trim the debugs out. I have to head to a meeting now - be back later.
Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#199217 - 2010-08-02 07:29 PM Re: KixGolf - Luhn's Mod [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
hmm .. my score is 140 but code fails, dunno why though
_________________________



Top
#199220 - 2010-08-02 07:55 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Did you try the $verbose=1 to see your results?
Top
#199221 - 2010-08-02 08:28 PM Re: KixGolf - Luhn's Mod [Re: Allen]
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Time to start shredding some strokes...

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Luhn's Mod
Processing Start = 2010/08/02 14:25:58.297
Processing End = 2010/08/02 14:25:58.375
Duration = 0000/00/00 00:00:00.078
# Tests Run = 50
# Tests Passed = 50
# Tests Failed = 0
Result = passed
KiXGolf Score = 249
_________________________
Eric

Top
#199222 - 2010-08-02 08:36 PM Re: KixGolf - Luhn's Mod [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Aye,

in the mean time it validates against amount of digits

Funny behaviour still:
works for AmKixpress, but fails to validate Kixa, MasterScript and Dectohex

Score 178

Edit:
Nice First Score Maciep!


Edited by Jochen (2010-08-02 08:50 PM)
_________________________



Top
#199223 - 2010-08-02 09:08 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany


KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_lm.kix

Computer
OS = Windows XP Professional
CPU = Intel Pentium Model 15
Speed = 2400 MHz
Memory = 2048 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Luhn's Mod
Processing Start = 2010/08/02 21:04:57.251
Processing End = 2010/08/02 21:04:57.266
Duration = 0000/00/00 00:00:00.014
# Tests Run = 50
# Tests Passed = 50
# Tests Failed = 0
Result = passed
KiXGolf Score = 191

Thank you for participating in KiXtart Golf!




Yay!

_________________________



Top
#199224 - 2010-08-02 09:10 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Well done, Jochen!

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Luhn's Mod
Processing Start = 2010/08/02 15:08:12.390
Processing End = 2010/08/02 15:08:12.390
Duration = 0000/00/00 00:00:00.000
# Tests Run = 50
# Tests Passed = 50
# Tests Failed = 0
Result = passed
KiXGolf Score = 215
_________________________
Eric

Top
#199225 - 2010-08-02 09:24 PM Re: KixGolf - Luhn's Mod [Re: maciep]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Nice shave Mace,


KiXtart
KiXtart Version  = 4.60
KiXGolf Script   = kixgolf_lm.kix

Computer
OS               = Windows XP Professional
CPU              = Intel Pentium Model 15
Speed            = 2400 MHz
Memory           = 2048 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.0.3

KiXtart Golf Score
Tournament       = KiXtart Golf: Luhn's Mod
Processing Start = 2010/08/02 21:22:58.157
Processing End   = 2010/08/02 21:22:58.173
Duration         = 0000/00/00 00:00:00.015
# Tests Run      = 50
# Tests Passed   = 50
# Tests Failed   = 0
Result           = passed
KiXGolf Score    = 180

Thank you for participating in KiXtart Golf!
_________________________



Top
#199226 - 2010-08-02 10:17 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
another classic "attaching-a-function-result-to-an-already-used-variable-rather-than-writing-teh-same-function-3-times-in-a-equation-condition" results in:

KiXtart KiXtart Version = 4.60 KiXGolf Script = kixgolf_lm.kix Computer OS = Windows XP Professional CPU = Intel Pentium Model 15 Speed = 2400 MHz Memory = 2048 MB KiXGolf Scoring Engine Scoring Engine = 3.0.3 KiXtart Golf Score Tournament = KiXtart Golf: Luhn's Mod Processing Start = 2010/08/02 22:15:11.626 Processing End = 2010/08/02 22:15:11.641 Duration = 0000/00/00 00:00:00.014 # Tests Run = 50 # Tests Passed = 50 # Tests Failed = 0 Result = passed KiXGolf Score = 177 Thank you for participating in KiXtart Golf!



Edited by Jochen (2010-08-02 11:16 PM)
_________________________



Top
#199227 - 2010-08-02 10:32 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
This one was a math-101 moment, aka: when you see it you'll sh* bricks

KiXtart
KiXtart Version  = 4.60
KiXGolf Script   = kixgolf_lm.kix

Computer
OS               = Windows XP Professional
CPU              = Intel Pentium Model 15
Speed            = 2400 MHz
Memory           = 2048 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.0.3

KiXtart Golf Score
Tournament       = KiXtart Golf: Luhn's Mod
Processing Start = 2010/08/02 22:29:53.476
Processing End   = 2010/08/02 22:29:53.491
Duration         = 0000/00/00 00:00:00.014
# Tests Run      = 50
# Tests Passed   = 50
# Tests Failed   = 0
Result           = passed
KiXGolf Score    = 168

Thank you for participating in KiXtart Golf!


_________________________



Top
#199228 - 2010-08-02 10:49 PM Re: KixGolf - Luhn's Mod [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany

KiXtart
KiXtart Version  = 4.60
KiXGolf Script   = kixgolf_lm.kix

Computer
OS               = Windows XP Professional
CPU              = Intel Pentium Model 15
Speed            = 2400 MHz
Memory           = 2048 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.0.3

KiXtart Golf Score
Tournament       = KiXtart Golf: Luhn's Mod
Processing Start = 2010/08/02 22:47:45.428
Processing End   = 2010/08/02 22:47:45.443
Duration         = 0000/00/00 00:00:00.014
# Tests Run      = 50
# Tests Passed   = 50
# Tests Failed   = 0
Result           = passed
KiXGolf Score    = 162

Thank you for participating in KiXtart Golf!


_________________________



Top
Page 1 of 9 12345>Last »


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

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.081 seconds in which 0.027 seconds were spent on a total of 15 queries. Zlib compression enabled.

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