#199431 - 2010-08-08 06:49 PM
Re: KixGolf: Luhn's Mod - Public Round
[Re: DrillSergeant]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
@Drill... Pure encryption... I love it It'll take a while for me to figure out that one.
|
Top
|
|
|
|
#199435 - 2010-08-08 07:46 PM
Re: KixGolf: Luhn's Mod - Public Round
[Re: DrillSergeant]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
here is my 185 code:
Function A($)
Dim $y,$x,$v
$x = Left($,1)
For $y = ($^) to 1 step -2
$a = 2 * SubStr($,$y-1,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
Edited by Benny69 (2010-08-08 07:56 PM)
|
Top
|
|
|
|
#199437 - 2010-08-08 07:49 PM
Re: KixGolf: Luhn's Mod - Public Round
[Re: Benny69]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
here is Eric's code at 135:
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
Edited by Benny69 (2010-08-08 07:56 PM)
|
Top
|
|
|
|
#199438 - 2010-08-08 07:57 PM
Re: KixGolf: Luhn's Mod - Public Round
[Re: Benny69]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
here is my other 185 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
Edited by Benny69 (2010-08-08 07:57 PM)
|
Top
|
|
|
|
#199440 - 2010-08-08 08:06 PM
Re: KixGolf: Luhn's Mod - Public Round
[Re: Lonkero]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Eric's at 134
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
Edited by Benny69 (2010-08-08 08:07 PM)
|
Top
|
|
|
|
#199443 - 2010-08-08 10:28 PM
Re: KixGolf: Luhn's Mod - Public Round
[Re: maciep]
|
BradV
Seasoned Scripter
Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
|
OK, I knew I was missing something! I'm embarrased to even post this.
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
|
Top
|
|
|
|
#199445 - 2010-08-08 11:08 PM
Re: KixGolf: Luhn's Mod - Public Round
[Re: BradV]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
Almost forgot... here is Jochen's 146
function a($)
dim $b, $c, $d
$b = 0^$
while $
$c = (($b-($^) & 1)+1) * right($,1)
$d = $d + $c-9*($c>9)
$a = ($d mod 10 =) * (($b=15&$=3)|$b=16&$>3&$<7) * $
$ = left($,~)
endfunction
|
Top
|
|
|
|
#199446 - 2010-08-09 12:51 AM
Re: KixGolf: Luhn's Mod - Public Round
[Re: Allen]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
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.
|
Top
|
|
|
|
#199447 - 2010-08-09 01:02 AM
Re: KixGolf: Luhn's Mod - Public Round
[Re: Benny69]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Brad's code at 240:
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 = $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)
$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
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 433 anonymous users online.
|
|
|