#199534  20100814 10:31 AM
Re: KixGolf: Luhn's Mod  Public Round
[Re: Lonkero]

Lonkero
KiX Master Guru
Registered: 20010605
Posts: 22346
Loc: OK

damn, I love bryce's code! awesome!
didn't dare to do too much, just removed the if's. score: 250
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)
_________________________
!download KiXnet

Top




#199536  20100814 10:45 AM
Re: KixGolf: Luhn's Mod  Public Round
[Re: Lonkero]

Lonkero
KiX Master Guru
Registered: 20010605
Posts: 22346
Loc: OK

another stap and bryce's code. commenting changes. 237
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
_________________________
!download KiXnet

Top




#199537  20100814 10:57 AM
Re: KixGolf: Luhn's Mod  Public Round
[Re: Lonkero]

Lonkero
KiX Master Guru
Registered: 20010605
Posts: 22346
Loc: OK

yet another stap at bryce's code. commenting changes. 211
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
_________________________
!download KiXnet

Top




Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart

1 registered
(Allen)
and 280 anonymous users online.


