


Gentleman, please post your code. 




Here's my 137 code Code: Function A($) dim $s,$f $a = 0 if $>3 & $<7 & len($)+($<4)=16 while $ $a = right($,1) $s = $s + $f*(9*(4<$a)+$a) + $a $ = left($,1) $f=1$f if $s mod 10 $a =0 Endfunction 




Hey Eric, would you mind explaining how you coded around these tests? 3456789012345675=0 valid luhn but 16 digits 456789012345671=0 valid luhn but 15 digits 567890123456781=0 "" 678901234567899=0 "" Edit...actually maybe its just a valid Amkixpress I would be interested in. 




Hey Maciep, our codes aren't that different! 124: Code: Function A($) Dim $c, $t While $ $A = 0 + right($, 1) $t = 1 & $c * ($A / 5 + $A) + $A + $t $c = $c + 1 $ = left($,~) If $t mod 10  $c15$A/4  4&$A + 5 $A = 0 Endfunction 




@Drill... Pure encryption... I love it It'll take a while for me to figure out that one. 




The two real kickers I added today were the binary calcutions: 1&$c and 4&$A + 5 The first one checks if the first bit of the digit is used, so this is true for every odd number and false for every even number. 1 = 0 0 0 1 = true 2 = 0 0 1 0 = false 3 = 0 0 1 1 = true 4 = 0 1 0 0 = false The second one is just like that. the variable $A kan be anything from 0 to 9. Because I needed a range of 4 digits to check I check against the 3rd bit(= weight=4). (3, 4, 5, 6) since my range starts at 3 but the first number with a false 3rd bit is 8 I need to add 5 to my number to check. so if we continue the table above: 2 + 5 = 7 = 0 1 1 1 = true (third bit = 1) Not correct 3 + 5 = 8 = 1 0 0 0 = false 4 + 5 = 9 = 1 0 0 1 = false 5 + 5 = 10 = 1 0 1 0 = false 6 + 5 = 11 = 1 0 1 1 = false 7 + 5 = 12 = 1 1 0 0 = true (third bit = true again) Not correct Does this make it any clearer? 




Quote: Hey Eric, would you mind explaining how you coded around these tests? 3456789012345675=0 valid luhn but 16 digits 456789012345671=0 valid luhn but 15 digits 567890123456781=0 "" 678901234567899=0 "" Edit...actually maybe its just a valid Amkixpress I would be interested in. I set $a to 0 by default. And then the if statement decides whether I even try to process string. Code: if $>3 & $<7 & len($)+($<4)=16 the first condition ensures that string doesn't start with 02. The second condition makes sure it doesn't start with 79. And the last condition makes sure that the length is 16 characters...but we need to add one if it starts with a 3. Since we are already discard 02, we can just check that it's less than 4 instead of exactly 3, so that condition will add 1 when appropriate. So if starts with a 3 and isn't 15 characters long, we never drop into the loop. Nice code Drill!! Definitely similar to mine, but you're golfing skillz are impressive! 




By the way, this is another sneaky move too: ($A / 5 + $A) If $A is a digit of 5 or greater, you need to add the two digits to get the relevant single digit number. The calculation above doesn't do that, but just adds another 1 if the number is 5 or greater. This will give: 5 + 5 = 10 + 1(because of $A/5) = 11` 6 + 6 = 12 + 1 = 13 7 + 7 = 14 + 1 = 15 Now for the check if it's divisble by 10 it doesn't matter if you add another extra 10 to the total, so I had the same calculation as Eric, (9 * ($A>4)) but replaced that (also today) for the calculation above. 




here is my 185 code: Code: Function A($) Dim $y,$x,$v $x = Left($,1) For $y = ($^) to 1 step 2 $a = 2 * SubStr($,$y1,1) $v = IIf($a > 9,$a / 10 + $a,$a) + $v + SubStr($,$y,1) $a = IIf(~ $v mod 10 & (($^) = 15 & $x = 3)  (($^) = 16 & $x > 3 & $x < 7),$x,0) ;Next EndFunction 




So my question then is this... if $>3 & $<7 wouldn't that only pickup 4  6? Edit... just saw this... "And the last condition makes sure that the length is 16 characters...but we need to add one if it starts with a 3. Since we are already discard 02, we can just check that it's less than 4 instead of exactly 3, so that condition will add 1 when appropriate. " Hmmm... need to process... cool though. 




here is Eric's code at 135: Code: Function A($) Dim $s,$f $a = 0 If $ > 3&$ < 7&($^)+($ < 4) = 16 While $ $a = Right($,1) $s = $s+$f*(9*(4 < $a)+$a)+$a $ = Left($,1) $f = 1$f If $s mod 10 $a = 0 EndFunction 




here is my other 185 code: Code: Function A($) Dim $z,$x,$v $z = Left($,1) $v = ($^) While $ $a = 2 * SubStr($,($^)1,1) $x = IIf($a > 9,$a / 10 + $a,$a) + Right($,1) + $x $ = Left($,2) $a = IIf(~ $x mod 10 & ($v = 15 & $z = 3)  ($v = 16 & $z > 3 & $z < 7),$z,0) ; Loop EndFunction 




lol, damn. the first one I was thinking about too, never used. second one. you have way too much energy! I have 2 versions of 134, I kinda like this the best: Code: Function A($b) dim $t,$,$x for $t=0 to 99 $=right($b,1) $x=$t mod 2*((4<$)+$)+$+$x $b=left($b,~) if $ $a=($t=15(3=$) & 2<$ & 7>$ & $x mod 10=0)*$ Endfunction 




Eric's at 134 Code: Function A($) Dim $s,$f $a = 0 If $ > 3&$ < 7&($^)+($<4) = 16 While $ $a = Right($,1) $s = $s+$f*(9*(4 < $a)+$a)+$a $ = Left($,~) $f = 1$f If $s mod 10 $a = 0 EndFunction 




Quote: if $>3 & $<7 wouldn't that only pickup 4  6? nope '3xxxxx' is greater than 3 too...found that out when $>2 failed a few cases 




Quote: Now for the check if it's divisble by 10 it doesn't matter if you add another extra 10 to the total, so I had the same calculation as Eric, (9 * ($A>4)) but replaced that (also today) for the calculation above. I KNEW there had to be a better way to do that...I like this one! I was pumped when I thought 2*$a mod 9 would work for all numbers...of course it failed for 9 




OK, I knew I was missing something! I'm embarrased to even post this. Code: Function A($) dim $l, $i, $b, $c, $x, $d $l = Len($) $d = Left($, 1) If ($d = 3 and $l = 15) or ($d > 3 and $d < 7 and $l = 16) $x = 0 For $i = $l  1 to 0 Step 1 $b = Substr($, $i + 1, 1) If ($l  $i) mod 2 = 0 $c = 2 * $b $b = IIF($c > 9, 0 + Left($c, 1) + Right($c, 1), $c) EndIf $x = $x + $b Next $d = IIF($x mod 10, 0, $d) Else $d = 0 EndIf $A = $d EndFunction 




Almost forgot... here is Jochen's 146 Code: function a($) dim $b, $c, $d $b = 0^$ while $ $c = (($b($^) & 1)+1) * right($,1) $d = $d + $c9*($c>9) $a = ($d mod 10 =) * (($b=15&$=3)$b=16&$>3&$<7) * $ $ = left($,~) endfunction 




Brad, Don't feel embarrased, you should feel proud, most can't even put somthing together that works, that is a BIG hurtle. I say well done, now lets see what we can do to shorten that code. 




Brad's code at 240: Code: Function A($) Dim $l,$i,$b,$c,$x,$d $l = ($^);Len($) $d = Left($,1) ;If($d = 3 And $l = 15) Or ( $d > 3 And $d < 7 And $l = 16 ) If($d = 3 & $l = 15)  ( $d > 3 & $d < 7 & $l = 16 ); use Bitwise Operators to do the same tasks as 'And' and 'Or' $x = 0 For $i = $l1 to 0 Step1 $b = SubStr($,$i+1,1) If($l$i) mod 2 = 0 $c = 2*$b ;$b = IIf($c > 9,0+Left($c,1)+Right($c,1),$c) $b = IIf($c > 9,$c / 10 + $c  10,$c); use a calulator to see that Kix drops the decimal for $c EndIf $x = $x + $b Next $d = IIf($x mod 10,0,$d) Else $d = 0 EndIf $A = $d EndFunction 




Brad, Another way to shorten code is to try dropping an 'EndIf' or 'Next' or 'Loop', if your code is well organized this might save a few strokes. Also try reusing the same variable in different sections of the code. Give it a try and show us what you come up with. 




I get an 'Expected,)!' error when I try Jochen's code. 




found it: $b = 0^$ was transposed, should be: $b = $^0 




Jochen, I love this bit of code: (($b  ($^) & 1) + 1) fliping between 1 and 2, dang creative, you da man. 




Interesting it doesn't work for you... works fine for me... using 4.61. 




yup, useing 4.61, transposed it works fine. 




???? works either way for me... strange stuff. 




well i guess that is the way the Bits fall off the Byte 




damn, here is my sherman tank (358) code... Code: Function A($) dim $i, $x, $b, $l $l = len($) if $l = 15 or $l = 16 redim $b[$l1] for $i = 0 to $l1 $b[$i] = substr($,$i+1,1) next for $i = $l2 to 0 step 2 $x = 2*$b[$i] $b[$i] = iif($x>9,0+left($x,1) + right($x,1),$x) next $i = execute("$X="+join($b,'+')) if right($x,1) = 0 $B = left($,1) if $b = 3 if $l <> 15 $b = 0 endif else if instr('456',$b) if $l <> 16 $b = 0 endif else $b = 0 endif endif else $b = 0 endif else $b = 0 endif $a = $b Endfunction I never really got beyond the "can i even do it phase" 




Originally Posted By: Benny69 Jochen, I love this bit of code: (($b  ($^) & 1) + 1) fliping between 1 and 2, dang creative, you da man. Wahey Dale, yeah, this was my last hope on sunday morning shaving further than 146 strokes, sparing one variable. But that turned out to be a dead end as I had to use much more parentheses than initially thought. Here's what it looked like before: Code: dim ... ,$b ... while $ $b = ~$b $c = (2+$b) * right($,1) .... So, there was no money in that either.. 




Borrowing the excellent idea Maciep had introducing into mine I would have had 140 .. Not that this would have changed the board but hey. I like the look of this Code: function a($) dim $b, $c, $d $b = 0^$ while $ $c = (($b($^) & 1)+1) * right($,1) $d = $d + $c9*($c>9) $a = ($d mod 10 =) * ($>2&$<7&$b+($<4)=16) * $ $ = left($,~) endfunction Funny how some things don't come to your mind when you stare at your own code for a week. 




here is Lonk's code at 133: Code: Function A($b) Dim $t,$,$x For $t=0 to 99 $=Right($b,1) $x=$t mod 2*((4<$)+$)+$+$x $b=Left($b,~) If $ $a=($t=15(3=$) & 2<$ & 7>$ & $x mod 10=)*$ EndFunction 




Back at the office  I can post my "179" code, with comments added Code: Function A($) Dim $D,$F,$I,$S ; Digit, Flag, ID, Sum $A=0 ; default return $D=Len($) ; CC # length $I=Left($,1) ; ; CC Issuer ID If ($D=15&$I=3)$D=16&$I>3&$I<7 ; verify ID/# Digits While $ ; while digits $D=(1+$F)*Right($,1) ; Get digit and optionally double $S=$S+IIf($D>9,$D9,$D) ; sum digit $F=$F^1 ; flip odd/even flag $=Left($,~) ; trim string Loop ; common code If $S Mod 10 = 0 ; if CC is valid $A=$I ; return issuer code EndFunction 




I've never seen/noticed this before (added to my list of cheats) ... nice! $F=$F^1 ; flip odd/even flag 




starting to look a bit like my code Originally Posted By: Benny69 here is Lonk's code at 133: Code: Function A($b) Dim $t,$,$x For $t=0 to 99 $=Right($b,1) $x=$t mod 2*((4<$)+$)+$+$x $b=Left($b,~) If $ $a=($t=15(3=$) & 2<$ & 7>$ & $x mod 10=)*$ EndFunction 




Originally Posted By: Allen I've never seen/noticed this before (added to my list of cheats) ... nice! $F=$F^1 ; flip odd/even flag If it had to be exactly 0 and 1 it'd be perfect. But we need to do (1+$f) before! in this loop.. So, as we can save one stroke (as shown a couple posts before) by doing: $F=~$F (toggling between 1 and 0 and afterwards! doing (2+$f)) my version should enter your cheat book too Edit: Aw, what the hell, here's my other version with 146: Code: function a($) dim $b, $c, $d, $e $e = $^0 while $ $b = ~$b $d = (2+$b) * right($,1) $c = $c + $d9*($d>9) $a = ($c mod 10 =) * (($e=15&$=3)$e=16&$>3&$<7) * $ $ = left($,~) endfunction See what I mean? 




OMG! I am such a dumbf***. Why haven't I seen this on sunday morning Code: function a($) dim $b, $d $b = 0^$ while $ $a = (($b($^) & 1)+1) * right($,1) $d = $d + $a9*($a>9) $a = ($d mod 10 =) * ($>2&$<7&$b+($<4)=16) * $ $ = left($,~) endfunction = 137 and the same for my other version: Code: function a($) dim $b, $c, $e $e = $^0 while $ $b = ~$b $a = (2+$b) * right($,1) $c = $c + $a9*($a>9) $a = ($c mod 10 =) * ($>2&$<7&$e+($<4)=16) * $ $ = left($,~) endfunction = 137 as well.. 




I really enjoy seeing the ingenious solutions presented in KiXgolf. @Drill  Wow, well done, I'm really impressed, I think your solution is fantastic! @Allen  I'm glad you put on such a good challenge. It's a pity Jen's didn't/couldn't play. It's such a selfless act to put on a challenge and it would have been good for him to finally get to play. As for me, I've played a couple of times in the past but never did very well. I would have liked to have played this time but was away on holidays (skiing). I hope more challenges come, they really demonstrate the flexibility of KiXtart and I think they're great for helping good scripters learn advanced techniques. Cheers, Richard 




benny, damn. good catch! that was stupid of me! 




129 out of mine: Code: Function A($b) Dim $t,$,$x For $t=0 to 99 $=0+Right($b,1) $x=1 & $t *($/5+$)+$+$x $b=Left($b,~) If $ $a=(2<$ & 7>$ & $t=14+$/4 & $x mod 10=)*$ EndFunction 




WTF!!!! 122 out of mine. Code: Function A($) Dim $t,$x For $t=0 to 15($<4) $a=Right($,1) $x=1 & $t *(($a>4)+$a)+$a+$x $a=(2<$a & 7>$ & $x mod 10=)*$a $=Left($,~) EndFunction 




119 out of drills code! Code: Function A($) Dim $c, $t For $c=0 to 15($<4) $A = 0 + right($, 1) $t = 1 & $c * ($A / 5 + $A) + $A + $t $ = left($,~) If $t mod 10 + $  4&$A + 5 $A = 0 Endfunction 




I just can't wrap my mind around the following line... Can you put this into words? If $t mod 10 + $  4&$A + 5 "If it fails the Luhn check..." 




driller explained the 4&$A + 5, $t mod 10 makes sense too, right? $ is any value left of the original value. so: if reminder + anyvalue_left or current_value smaller than 3 or greater than 6 the anyvalue_left reverts back to the for loop. the loop goes 16 times (or 15, if left(input,1)=3) if after that, any value is left to be processed => over length of input. ok, hope that made any sense. 




oh, and in your words. if it fails the check + is too long or is not acceptable card I guess I could have used  instead of + never even considered though. 




same tweak is sneaky in my code too, where: $a=(2<$a & 7>$ ... if currentvalue is more than 2 and currentval PLUS any reminder values is less than 7... 




Thanks... truly amazing. My mind just doesn't think that way. Is it any wonder I never really compete with you guys? 




well, I still don't fully crasp the kixtart binary logic. way too fuzzy. kudos to drill about that. iirc hobie was one of those binary boys too. but playing with numbers and making them dance for you... that I would consider my field 




I think that I've discovered the secret of the way Lonk's brain works: Originally Posted By: Jukka "Yucca" Korpela I will conclude with a proof that Finnish has an infinite number of words. In Finnish, there is a derived word for any numeral, corresponding in meaning the words in the sequence simple, double, triple, etc. You take the numeral, make it one word, and append the word kertainen possibly after some changes to the stem. Thus from tuhat viisi ‘1005’ we get tuhatviisikertainen. And generally, there is the sequence of numerals yksinkertainen, kaksinkertainen, kolminkertainen and so on – literally ad infinitum. Taken from http://www.cs.tut.fi/~jkorpela/lang/vocab.html 




I can't even understand that! 




Originally Posted By: Lonkero 119 out of drills code! Code: Function A($) Dim $c, $t For $c=0 to 15($<4) $A = 0 + right($, 1) $t = 1 & $c * ($A / 5 + $A) + $A + $t $ = left($,~) If $t mod 10 + $  4&$A + 5 $A = 0 Endfunction Damn! I don't think I even tried a fornext loop because I didn't believe it would be shorter. Thanx for proving me wrong, you damn basta! ;) 




I'm not sure why it works, but... 114! Code: ; begin Luhns Mod ; ;! Function A($) Dim $c, $t For $c=0 to 15($<4) $A = 0 + right($, 1) $t = 1 & $c * ($A / 5 + $A) + $A + $t $ = left($,~) If $t + $  4&$A + 5 $A = 0 Endfunction ;! ;! ; end Luhns Mod 




Maybe I'm wrong, but isn't $t supposed to be the sum total? Because it appears that $T is returning nothing but 0s and 1s... which just happen to always return the proper value for the luhn check in the end... So are we missing a test or is this a Jedi Mind trick? 




It is dark voodoo indeed... If you put 1 & $c between round brackets and put the mod 10 back where it was you'll see that $T does indeed contain the total... I noticed that when I removed the brackets I lost the value of $T but because the tests still came up as valid I went with it... and today I found out that it doesn't even need the mod 10 to work... $T as expected: Code: ; begin Luhns Mod ; ;! Function A($) Dim $c, $t ? For $c=0 to 15($<4) $A = 0 + right($, 1) $t = (1 & $c) * ($A / 5 + $A) + $A + $t $ = left($,~) $t " " If $t mod 10 + $  4&$A + 5 $A = 0 Endfunction ;! ;! ; end Luhns Mod Voodoo $T: Code: ; begin Luhns Mod ; ;! Function A($) Dim $c, $t ? For $c=0 to 15($<4) $A = 0 + right($, 1) $t = 1 & $c * ($A / 5 + $A) + $A + $t $ = left($,~) $t " " If $t + $  4&$A + 5 $A = 0 Endfunction ;! ;! ; end Luhns Mod Or maybe I just sold my soul to the devil to win ;) 




I can completely see why the mod 10 check is unnecessary when you are getting the proper 0 or 1 value in $t... but how its doing this without a true total is a complete mystery to me. So how hot is it down there? 




Originally Posted By: Lonkero well, I still don't fully crasp the kixtart binary logic. way too fuzzy. kudos to drill about that. iirc hobie was one of those binary boys too. but playing with numbers and making them dance for you... that I would consider my field Well, there are 10 guys who really understand KiXtart binary logic (Ruud not included), and these are Rogier and Howard M) edit: on second thought make that 11 and add Richard to the list. maybe even 100 including Remco 




what? Code: ;pseudo: if $t + $  whateva $a = 0 I can't get why $t should be 0 in any case edit: Maybe I don't want to know this.. there be dragons 




oh, I see .. Operator Precedence 1. ($a / 5 + $a) 2. + $a 3. + $t 4. * $c 5. 1 & (result of 1.  4.) Now that I just realized what might going on... how much time is left until the '19th Hole' ? btw. Rogier: 4&$a+5 ... breathtaking move as well! 




nothing to do with voodoo. the line: $t = 1 & $c * ($A / 5 + $A) + $A + $t is just the same as: $t = 1 & ($c * ($A / 5 + $A) + $A + $t) still trying to figure out what it does, but some day I will get to it 




somebody please comment but it actually looks like a "mod 2" statement. but it is not. (tested it :)) anyhow... something is not cool in there. 




ok, after looking at these.... damn. I was trying to rethink of a way to do everything in a single loop my self, but i just got back in town last night. So i had no real time to sit and think about it. Nice job! 




bryce, funny cause when I started with this one, I didn't have a loop at all 




introducing new test case and leading score of 124 Code: Function A($) Dim $t,$x For $t=0 to 15($<4) $a=Right($,1) $x=$t mod 2 *(($a>4)+$a)+$a+$x $a=(2<$a & 7>$ & $x mod 10=)*$a $=Left($,~) EndFunction test 64: 378282244310005=0 




and new leading score of 121 Code: Function A($) Dim $c, $t For $c=0 to 15($<4) $A = 0 + right($, 1) $t = $c mod 2 * ($A / 5 + $A) + $A + $t $ = left($,~) If $t mod 10 + $  4&$A + 5 $A = 0 Endfunction 




and there was no voodoo involved. it was all about too "linear" test cases. drill's shortcut actually just did do what it was supposed to, test for 1 & x 




Why Yes, mr Devil, I'm also willing to sign over my kidneys to you 119: Code: ; begin Luhns Mod ; ;! Function A($) Dim $c, $t For $c=0 to 15($<4) $A = 0 + right($, 1) $t = $c mod 2 * ($A / 5 + $A) + $A + $t $ = left($,~) If $t mod 10  4&$A + 5 $A = 0 Endfunction ;! ;! ; end Luhns Mod 




wtf. thought I tested that! 




k, one more test case and I'm back in the lead 30378282246310005=0 




kinda weird competition this time :P 




Refereeee!??!!11eleven nB.: I guess I should face the facts for the public round. Work is too tough on Workdays (doing the standin for two colls in vacation) and my family life schedule will be too full this weekend. So, I am looking forward to the next round which will hopefully start soon. 




LOL... never seen a competition of who can come up with a test to break code like this before... Sorry guys... I'll try to do better next time... @Jochen... it could be a while before I'm ready for the next one... but the good news is, I have about 5 good ideas right now. 




Originally Posted By: Allen LOL... never seen a competition of who can come up with a test to break code like this before... NP Allen, it's happened before We had this discussion in the past: should it follow the set of rules or just pass the given INI? I believe we settled on following the rules, so a part of golf is indeed to come up with new tests that could break the other guys code, as long as you stay within the parameters of the assignment. 




yes. but the private code standings stay, if they passed those tests. 




glenn's at 149: Code: Function A($D) Dim $,$F,$S ; Digit, Flag, ID, Sum $A=0 $=Left($D,1) ; ; CC Issuer ID If ($D^)+($=3)=16 & $>2 & $<7 ; verify ID/# Digits While $D ; while digits $=Right($D,1) ; Get digit and optionally double $S=$S+$F*((4<$)+$)+$ ; sum digit $F=$F^1 ; flip odd/even flag $D=Left($D,~) ; trim string $A=($S Mod 10 =)*$ ; if CC is valid EndFunction 




132 from jochen's: Code: function a($) dim $b, $d while $ $a = right($,1) $d = $d + (1&$b)*((4<$a)+$a)+$a $b=$b+1 $a = ($d mod 10 =) * ($>2&$<7&$b+($<4)=16) * $ $ = left($,~) endfunction 




damn, I love bryce's code! awesome! didn't dare to do too much, just removed the if's. score: 250 Code: Function A($) dim $i, $x, $b, $l $l = len($) redim $b[$l1] for $i = 0 to $l1 $b[$i] = substr($,$i+1,1) next for $i = $l2 to 0 step 2 $x = 2*$b[$i] $b[$i] = iif($x>9,0+left($x,1) + right($x,1),$x) next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $l=16($<4) & $x mod 10=)*left($,1) 




hmm... I guess everyone has given up already. current (unofficial!) standings on public would then be something like: Lonkero  121 (based on drill) Benny  133 (based on Lonk) Maciep  137 (own from private) Jochen  137 (own from private, improved) Glenn  179 (own from private) BradV  262 (own from private) Bryce  358 (own from private) 




another stap and bryce's code. commenting changes. 237 Code: Function A($) $a = $^0 ;no need for long keywords like len() dim $i, $x, $b[$a1] ;$l removed using $a instead ;redim $b[$a1] ;no need to redim if doing right in the start ;) for $i = 0 to $a1 $b[$i] = substr($,$i+1,1) next for $i = $a2 to 0 step 2 $x = 2*$b[$i] $b[$i] = iif($x>9,0+left($x,1) + right($x,1),$x) next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction 




yet another stap at bryce's code. commenting changes. 211 Code: Function A($) $a = $^0 ;no need for long keywords like len() dim $i, $x, $b[$a1] ;$l removed using $a instead ;redim $b[$a1] ;no need to redim if doing right in the start ;) for $i = 0 to $a1 $b[$i] = substr($,$i+1,1) next for $i = $a2 to 0 step 2 $x = 2*$b[$i] ; $b[$i] = iif($x>9,0+left($x,1) + right($x,1),$x) redone without lettercode (right replaced with mod). ;$b[$i] = iif($x>9,0+left($x,1) + $x mod 10,$x) x cannot be more than 18, so removing left(). also removing iif. $b[$i] = $x9*($x>9) next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction 




still going at it. for documentation purposes, posting before continuing. 210 Code: Function A($) $a = $^0 ;no need for long keywords like len() dim $i, $x, $b[$a1],$s ;$l removed using $a instead. $s introduced as "swinger" ;redim $b[$a1] ;no need to redim if doing right in the start ;) for $i = $a1 to 0 step 1 $x = substr($,$i+1,1) if $s ;second for loop removed. using swinger swapper instead. $x = 2*$x $x = $x9*($x>9) endif $b[$i] = $x $s=$s^1 next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction 




still going at it. for documentation purposes, posting before continuing. 203 Code: Function A($) $a = $^0 dim $i, $x, $b[$a1],$s for $i = $a1 to 0 step 1 $x = substr($,$i+1,1) if $s ;$x = 2*$x ;$x = $x9*($x>9) $x = 2*$x+(4<$x) ; above lines combined endif $b[$i] = $x $s=$s^1 next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction 




bryce's 195 Code: Function A($) $a = $^0 dim $i, $x, $b[$a1],$s for $i = $a1 to 0 step 1 $x = substr($,$i+1,1) ; if $s ; $x = 2*$x+(4<$x) ; endif $b[$i] = $s*((4<$x)+$x)+$x ;replaces the commented out if statement $s=$s^1 next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction 




bryce's at 189 Code: Function A($) $a = $^0 dim $i, $x, $b[$a1],$s ; for $i = $a1 to 0 step 1 too long. fixing. for $i = $a to 1 $x = substr($,$i,1) $b[~$i] = $s*((4<$x)+$x)+$x $s=$s^1 next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction 




I AM HAVING TOO MUCH FUN! 120, new leader again :P Code: Function A($) Dim $c, $t For $c=0 to 15($<4) $A = 0 + right($, 1) $t = (1&$c) * (1.1*$A) + $A + $t $ = left($,~) If $t mod 10 + $  4&$A + 5 $A = 0 Endfunction 




the same "trick" brings "mine" to 121 Code: Function A($) Dim $t,$x For $t=0 to 15($<4) $a=Right($,1) $x=(1&$t) *(1.1*$a)+$a+$x $a=(2<$a & 7>$ & $x mod 10=)*$a $=Left($,~) EndFunction 




how stupid of me. my code is at 120 as well. Code: Function A($) Dim $t,$x For $t=0 to 15($<4) $a=Right($,1) $x=(1&$t) *(1.1*$a)+$a+$x $a=(2<$ & 7>$ & $x mod 10=)*$a $=Left($,~) EndFunction 




118 Code: Function A($) Dim $c, $t For $c=0 to 15($<4) $A = 0 + right($, 1) $t = $A + 1.1*$A*(1&$c) + $t $ = left($,~) If $t mod 10 + $  4&$A + 5 $A = 0 Endfunction 




Nice Lonk... $a=(2<$ & 7>$ & $x mod 10=)*$a This is the line I was hunting for when I was fooling with it... I knew there had to be a way to do it without just setting $a=0. $x=(1&$t) *(1.1*$a)+$a+$x 1.1 eh? I'm still trying to understand how this works... looking at it now 




Quote: By the way, this is another sneaky move too: ($A / 5 + $A) If $A is a digit of 5 or greater, you need to add the two digits to get the relevant single digit number. The calculation above doesn't do that, but just adds another 1 if the number is 5 or greater. This will give: 5 + 5 = 10 + 1(because of $A/5) = 11` 6 + 6 = 12 + 1 = 13 7 + 7 = 14 + 1 = 15 Now for the check if it's divisble by 10 it doesn't matter if you add another extra 10 to the total, so I had the same calculation as Eric, (9 * ($A>4)) but replaced that (also today) for the calculation above. I finally see it! That is so slick and using the 1.1 is just a shortcut of Drills... very nice guys. 




@Lonk... if you'll fix that code so it has the function line and dims, I'll try it with 4.61 




oops. sorry. fixed. 




and I refuse to admit 1.1 is shortcut of drill's as my code used similar logic 




k, not sure what I missed with the above code, but I promise you, I got error on line 1 or 9 with it. 




It worked... but failed the tester... Code: KiXtart Golf Score Tournament = KiXtart Golf: Luhn's Mod Processing Start = 2010/08/14 12:05:58.799 Processing End = 2010/08/14 12:05:58.808 Duration = 0000/00/00 00:00:00.008 # Tests Run = 40 # Tests Passed = 26 # Tests Failed = 14 Result = failed KiXGolf Score = 126 




Originally Posted By: Lonkero bryce's at 189 Code: Function A($) $a = $^0 dim $i, $x, $b[$a1],$s ; for $i = $a1 to 0 step 1 too long. fixing. for $i = $a to 1 $x = substr($,$i,1) $b[~$i] = $s*((4<$x)+$x)+$x $s=$s^1 next $i = execute("$X="+join($b,'+')) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction damn lonk! that is truly amazing i can tell you i would have never gotten my code to that. 




oh. wasn't done with it just yet though :P 




yeah... removing the need for array is the next step and then it becomes pretty close already to the other ones. 177. Code: Function A($) $a = $^0 dim $i, $x, $b,$s for $i = $a to 1 $x = substr($,$i,1) $b = $b+'+'+($s*((4<$x)+$x)+$x) $s=$s^1 next $i = execute("$X="+$b) $a = ($>3 & $<7 & $a=16($<4) & $x mod 10=)*left($,1) Endfunction then execution becomes pointless... 151 Code: Function A($) $a = $^0 dim $i, $x, $b,$s for $i = $a to 1 $x = substr($,$i,1) $b = $b+$s*((4<$x)+$x)+$x $s=$s^1 next $a = ($>3 & $<7 & $a=16($<4) & $b mod 10=)*left($,1) Endfunction 




still, redoing bryce's... 145 Code: Function A($) dim $i, $x, $b,$s for $i = ($^) to 1 $x = substr($,$i,1) $b = $b+$s*((4<$x)+$x)+$x $s=$s^1 $a = ($>3 & $<7 & ($^)=16($<4) & $b mod 10=)*left($,1) Endfunction 




bryce's down to 138 Code: Function A($) dim $i, $x, $b,$s for $i = ($^) to 1 $x = substr($,$i,1) $b = $b+$s*((4<$x)+$x)+$x $s=$s^1 $a = ($>3 & $<7 & ($^)=16($<4) & $b mod 10=)*$x Endfunction 




so... do we have all of 15th to code or will it end when we reach 7 days? 




It ends at 12:00 US eastern time.. about 12 hours from now. 




us eastern time? you mean EST or EDT or something else? 




end is anyways in 32 mins, right? 




Something like that... it's officially over now. 




wohoo. someone didn't get any score from public! yehaa. :p 




thanks for the fun thought, to all of you! specially thanks allen for hosting and drill for making it challenging! 




I've sent an email to Jens asking for some clarification of scoring... I'll post the scores as soon as I hear back from him. 




With my interpretation of the rules... 




I must disagree with the ruling. only the codes that get a succesfull score within public round that passes all the testing, even the new ones, are egilible for points. 




I had to assume you were protesting Drills 124... I didn't realize it failed the public tests... please be a little clearer on your future protests. The management Scores updated above. 




lol. awesome. 




Jooel... No more protest? Are you censoring yourself now? 




well... not censoring. decided to sleep for a bit. 




hmm... not a protest but reading the rules, I think you found an old scoring engine. it didn't work with block comments but again, thanks for the fun allen. 




How do you get half points? 




By dividing by 2. 




I though maybe it was a rounding error Maybe the next challenge should be the KiXgolf scoring engine  the Ouroboros challenge. 