Page 5 of 6 « First<23456>
Topic Options
#199541 - 2010-08-14 11:45 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
still going at it. for documentation purposes, posting before continuing.
203
 Code:
Function A($)	
	$a = $^0
	dim $i, $x, $b[$a-1],$s
	
		for $i = $a-1 to 0 step -1
			$x = substr($,$i+1,1)
			if $s
				;$x = 2*$x
				;$x = $x-9*($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
_________________________
!

download KiXnet

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
bryce's 195
 Code:
Function A($)	
	$a = $^0
	dim $i, $x, $b[$a-1],$s
	
		for $i = $a-1 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
_________________________
!

download KiXnet

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
bryce's at 189
 Code:
Function A($)	
	$a = $^0
	dim $i, $x, $b[$a-1],$s

;		for $i = $a-1 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
_________________________
!

download KiXnet

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

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

download KiXnet

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

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

download KiXnet

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

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

download KiXnet

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

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

download KiXnet

Top
#199550 - 2010-08-14 02:00 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

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

Top
#199551 - 2010-08-14 02:10 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

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

Top
#199552 - 2010-08-14 02:13 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
@Lonk... if you'll fix that code so it has the function line and dims, I'll try it with 4.61
Top
#199553 - 2010-08-14 03:07 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oops. sorry. fixed.
_________________________
!

download KiXnet

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
and I refuse to admit 1.1 is shortcut of drill's as my code used similar logic ;\)


Edited by Lonkero (2010-08-14 03:17 PM)
_________________________
!

download KiXnet

Top
#199555 - 2010-08-14 03:34 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, not sure what I missed with the above code, but I promise you, I got error on line 1 or 9 with it.
_________________________
!

download KiXnet

Top
#199558 - 2010-08-14 06:09 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

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

Top
#199562 - 2010-08-14 06:41 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
 Originally Posted By: Lonkero
bryce's at 189
 Code:
Function A($)	
	$a = $^0
	dim $i, $x, $b[$a-1],$s

;		for $i = $a-1 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.

Top
#199563 - 2010-08-14 07:38 PM Re: KixGolf: Luhn's Mod - Public Round [Re: Bryce]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh. wasn't done with it just yet though :P
_________________________
!

download KiXnet

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

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

download KiXnet

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

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

download KiXnet

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

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

download KiXnet

Top
#199571 - 2010-08-15 02:18 AM Re: KixGolf: Luhn's Mod - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so...
do we have all of 15th to code or will it end when we reach 7 days?
_________________________
!

download KiXnet

Top
Page 5 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 280 anonymous users online.
Newest Members
Jojo67, MaikSimon, kvn317, kixtarts2025, SERoyalty
17873 Registered Users

Generated in 0.08 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

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