Page 4 of 6 « First<23456>
Topic Options
#199496 - 2010-08-11 10:20 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3165
Loc: Houston TX
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!

Top
#199497 - 2010-08-12 05:11 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Bryce]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
bryce, funny cause when I started with this one, I didn't have a loop at all \:\)
_________________________
!

download KiXnet

Top
#199508 - 2010-08-12 06:24 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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
_________________________
!

download KiXnet

Top
#199510 - 2010-08-12 06:25 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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
_________________________
!

download KiXnet

Top
#199511 - 2010-08-12 06:32 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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
_________________________
!

download KiXnet

Top
#199512 - 2010-08-12 07:50 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
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
_________________________
The Code is out there

Top
#199513 - 2010-08-12 08:11 PM Re: KixGolf: Luhn's Mod - Public Round [Re: DrillSergeant]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
wtf. thought I tested that!
_________________________
!

download KiXnet

Top
#199515 - 2010-08-12 08:23 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
k, one more test case and I'm back in the lead \:D

30378282246310005=0
_________________________
!

download KiXnet

Top
#199516 - 2010-08-12 08:25 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
kinda weird competition this time :P
_________________________
!

download KiXnet

Top
#199517 - 2010-08-12 09:08 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Refereeee!??!!11eleven

nB.: I guess I should face the facts for the public round. Work is too tough on Workdays (doing the stand-in 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.


Edited by Jochen (2010-08-12 09:14 PM)
Edit Reason: throwing in the towel
_________________________



Top
#199519 - 2010-08-12 09:28 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Jochen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4510
Loc: USA
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.

Top
#199521 - 2010-08-12 10:09 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Allen]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
 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.
_________________________
The Code is out there

Top
#199522 - 2010-08-12 11:28 PM Re: KixGolf: Luhn's Mod - Public Round [Re: DrillSergeant]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
yes. but the private code standings stay, if they passed those tests.
_________________________
!

download KiXnet

Top
#199532 - 2010-08-14 09:16 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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
_________________________
!

download KiXnet

Top
#199533 - 2010-08-14 10:01 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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
_________________________
!

download KiXnet

Top
#199534 - 2010-08-14 10:31 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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[$l-1]
		for $i = 0 to $l-1
			$b[$i] = substr($,$i+1,1)
		next

		for $i = $l-2 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
#199535 - 2010-08-14 10:35 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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)
_________________________
!

download KiXnet

Top
#199536 - 2010-08-14 10:45 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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[$a-1] ;$l removed using $a instead
	
		;redim $b[$a-1] ;no need to redim if doing right in the start ;)
		for $i = 0 to $a-1
			$b[$i] = substr($,$i+1,1)
		next

		for $i = $a-2 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 - 2010-08-14 10:57 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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[$a-1] ;$l removed using $a instead
	
		;redim $b[$a-1] ;no need to redim if doing right in the start ;)
		for $i = 0 to $a-1
			$b[$i] = substr($,$i+1,1)
		next

		for $i = $a-2 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] = $x-9*($x>9)
		next

		$i = execute("$X="+join($b,'+'))

	$a = ($>3 & $<7 & $a=16-($<4) & $x mod 10=)*left($,1)
Endfunction
_________________________
!

download KiXnet

Top
#199538 - 2010-08-14 11:12 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
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[$a-1],$s ;$l removed using $a instead. $s introduced as "swinger"
	
		;redim $b[$a-1] ;no need to redim if doing right in the start ;)
		for $i = $a-1 to 0 step -1
			$x = substr($,$i+1,1)
			if $s ;second for loop removed. using swinger swapper instead.
				$x = 2*$x
				$x = $x-9*($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
_________________________
!

download KiXnet

Top
Page 4 of 6 « First<23456>


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

Who's Online
1 registered (Allen) and 221 anonymous users online.
Newest Members
dimi575, Drecksnacken, Nlill, webtools321, multiman
17734 Registered Users

Generated in 0.044 seconds in which 0.013 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