#191565 - 2009-01-03 05:56 PM
Re: KiXgolf: Latin Squares - public round
[Re: Sealeopard]
|
DrillSergeant
MM club member
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
well, here's my code. I wonder if it's the same approach as all the others
it's a score of 404 instead of 405 because I changed a "" to @, but since it didn't influence the ranking in this round I forgot to post it in the private round.
Well Jooel, your turn to pull this one through the Lonkenizer(tm)
; begin KiXgolfUDF
;
;!
Function S($o)
Dim $i, $, $k, $t, $x
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $i = 0 to 3
For $ = 0 to 3
$k = iif($i<2,iif($<2,0,1),iif($<2,2,3))
$t = $o[$i,$]
$r[$] = $r[$] + $t
$c[$i] = $c[$i] + $t
$q[$k] = $q[$k] + $t
$s[$i, $, $x] = $t
Next
Next
if instr(join($r),x)=0
exit
endif
For $i = 0 to 3
For $ = 0 to 3
$k=@
for $t = 1 to 4
if instr($c[$i]+$r[$]+$q[iif($i<2,iif($<2,0,1),iif($<2,2,3))],$t)=0 & $o[$i,$]=x
$k=$k+$t
endif
next
if ($k^)=1
$o[$i,$]=$k
$i=3 $=3
EndFunction
;!
;!
; end KiXgolfUDF
Your solution passed all tests
KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_ls.KIX
Computer
OS = Windows Vista Business Edition
CPU = Intel Pentium Model 15
Speed = 2194 MHz
Memory = 2038 MB
KiXGolf Scoring Engine
Scoring Engine = 3.3
KiXtart Golf Score
Tournament = Latin Squares
Processing Start = 2009/01/03 17:49:57.734
Processing End = 2009/01/03 17:49:58.263
Duration = 0000/00/00 00:00:00.529
KiXGolf Score = 404
Thank you for participating in KiXtart Golf!
_________________________
The Code is out there
|
Top
|
|
|
|
#191571 - 2009-01-04 12:22 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
DrillSergeant
MM club member
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
For everyone else who likes to join, but can't read the code, here's my code with explanation:
; begin KiXgolfUDF
;
;!
Function S($o)
Dim $i, $, $k, $t, $x
; Create a loop for the maximum number of x-es. (There are 16 fields)
For $x = 0 to 16
; empty the row, column and square arrays and add one dimension to the solution array for current encountered x.
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
;loop through each column
For $i = 0 to 3
;loop through each row
For $ = 0 to 3
; retrieve the field from the original array
$t = $o[$i,$]
; find the corresponding square.
; 0 0 1 1
; 0 0 1 1
; 2 2 3 3
; 2 2 3 3
$k = iif($i<2,iif($<2,0,1),iif($<2,2,3))
; fill the row with all variables on that row
$r[$] = $r[$] + $t
; fill the column with all variables in that column
$c[$i] = $c[$i] + $t
; fill the square with all variables in that square
$q[$k] = $q[$k] + $t
; fill the solution array with the current variable
$s[$i, $, $x] = $t
Next
Next
; if there are no more x-es in the rows, exit the function
if instr(join($r),x)=0
exit
endif
For $i = 0 to 3
For $ = 0 to 3
$k=@
; Loop through each possible number (1,2,3 or 4)
for $t = 1 to 4
; If current variable is an x and the number ($t) does not exist in the corresponding row, column or square, add it to the variable $k
if instr($c[$i]+$r[$]+$q[iif($i<2,iif($<2,0,1),iif($<2,2,3))],$t)=0 & $o[$i,$]=x
$k=$k+$t
endif
next
; If there's only one digit in the variable $k, this means that that's the only solution for that x, so we can change that field in the initial array.
if ($k^)=1
$o[$i,$]=$k
; we reset the $i and $j so that we exit these loops and start at the beginning of the $x loop again.
$i=3 $=3
EndFunction
;!
;!
; end KiXgolfUDF
_________________________
The Code is out there
|
Top
|
|
|
|
#191588 - 2009-01-05 08:10 AM
Re: KiXgolf: Latin Squares - public round
[Re: DrillSergeant]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
k, got my computer at hand. nobody seems to listen when I say iif() is bad...
Your solution passed all tests
KiXtart KiXtart Version = 4.53 KiXGolf Script = kixgolf_ls.kix
Computer OS = Windows XP Professional CPU = AMD Turion(tm) 64 X2 Mobile Technology TL-64 Speed = 2194 MHz Memory = 1920 MB
KiXGolf Scoring Engine Scoring Engine = 3.3
KiXtart Golf Score Tournament = Latin Squares Processing Start = 2009/01/05 09:09:29.093 Processing End = 2009/01/05 09:09:29.187 Duration = 0000/00/00 00:00:00.093 KiXGolf Score = 366
Function S($o)
Dim $i, $, $k, $t, $x
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $i = 0 to 3
For $ = 0 to 3
$k = 3-2*($i<2)-($<2)
$t = $o[$i,$]
$r[$] = $r[$] + $t
$c[$i] = $c[$i] + $t
$q[$k] = $q[$k] + $t
$s[$i, $, $x] = $t
Next
Next
if instr(join($r),x)=0
exit
endif
For $i = 0 to 3
For $ = 0 to 3
$k=@
for $t = 1 to 4
if instr($c[$i]+$r[$]+$q[3-2*($i<2)-($<2)],$t)=0 & $o[$i,$]=x
$k=$k+$t
endif
next
if ($k^)=1
$o[$i,$]=$k
$i=3 $=3
EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#191589 - 2009-01-05 08:44 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
364
Function S($o)
Dim $i, $, $k, $t, $x
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $i = 0 to 3
For $ = 0 to 3
$k = 3-2*($i<2)-($<2)
$t = $o[$i,$]
$r[$] = $r[$] + $t
$c[$i] = $c[$i] + $t
$q[$k] = $q[$k] + $t
$s[$i, $, $x] = $t
Next
Next
if instr(join($r),x)=0
exit
endif
For $ = 0 to 3
For $i = 0 to 3
$k=@
for $t = 1 to 4
if 0=instr($c[$]+$r[$i]+$q[3-2*($<2)-($i<2)],$t) + $o[$,$i]
$k=$k+$t
endif
next
if 1=($k^)
$o[$,$i]=$k
$=3 $i=3
EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#191597 - 2009-01-05 10:49 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
heh.
I bet I forgot something = you got easy picking to do...
Function S($o)
Dim $i, $, $k, $t, $x
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $i = 0 to 7
For $ = 0 to 3
if $i<4
$k = 3-2*($i<2)-($<2)
$t = $o[$i,$]
$r[$] = $r[$] + $t
$c[$i] = $c[$i] + $t
$q[$k] = $q[$k] + $t
$s[$i, $, $x] = $t
if 0=instr(join($r),x) & $i=3 & $=3
exit
endif
else
$k=@
for $t = 1 to 4
if 0=instr($c[$i-4]+$r[$]+$q[3-2*($i<6)-($<2)],$t) + $o[$i-4,$]
$k=$k+$t
endif
next
if 1=($k^)
$o[$i-4,$]=$k
$i=7 $=3
EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#191598 - 2009-01-05 10:53 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
yep... 361
Function S($o)
Dim $i, $, $k, $t, $x
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $ = 0 to 7
For $i = 0 to 3
if $<4
$k = 3-2*($<2)-($i<2)
$t = $o[$,$i]
$r[$i] = $r[$i] + $t
$c[$] = $c[$] + $t
$q[$k] = $q[$k] + $t
$s[$, $i, $x] = $t
if 0=instr(join($r),x) & $i=3 & $=3
exit
endif
else
$k=@
for $t = 1 to 4
if 0=instr($c[$-4]+$r[$i]+$q[3-2*($<6)-($i<2)],$t) + $o[$-4,$i]
$k=$k+$t
endif
next
if 1=($k^)
$o[$-4,$i]=$k
$=7 $i=3
EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#191599 - 2009-01-05 10:57 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
lol.
352
Function S($o)
Dim $i, $, $k, $t, $x
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $ = 0 to 7
For $i = 0 to 3
if $<4
$k = 3-2*($<2)-($i<2)
$t = $o[$,$i]
$r[$i] = $r[$i] + $t
$c[$] = $c[$] + $t
$q[$k] = $q[$k] + $t
$s[$, $i, $x] = $t
else
if 0=instr(join($r),x)
exit
endif
$k=@
for $t = 1 to 4
if 0=instr($c[$-4]+$r[$i]+$q[3-2*($<6)-($i<2)],$t) + $o[$-4,$i]
$k=$k+$t
endif
next
if 1=($k^)
$o[$-4,$i]=$k
$=7 $i=3
EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#191600 - 2009-01-05 10:59 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
351
Function S($o)
Dim $i, $, $k, $t, $x
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $ = 0 to 7
For $i = 0 to 3
if $<4
$k = 3-2*($<2)-($i<2)
$t = $o[$,$i]
$r[$i] = $r[$i] + $t
$c[$] = $c[$] + $t
$q[$k] = $q[$k] + $t
$s[$, $i, $x] = $t
else
if 0=instr(join($r),x)
exit
else
$k=@
for $t = 1 to 4
if 0=instr($c[$-4]+$r[$i]+$q[3-2*($<6)-($i<2)],$t) + $o[$-4,$i]
$k=$k+$t
endif
next
if 1=($k^)
$o[$-4,$i]=$k
$=7 $i=3
EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#191601 - 2009-01-05 11:14 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
ok, now need to get back to work.
350
Function S($o)
Dim $i, $, $k, $t, $x,$v
For $x = 0 to 16
Redim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $ = 0 to 7
For $i = 0 to 3
$v = $o[$ mod 4,$i]
if $<4
$k = 3-2*($<2)-($i<2)
$r[$i] = $r[$i] + $v
$c[$] = $c[$] + $v
$q[$k] = $q[$k] + $v
$s[$, $i, $x] = $v
else
if 0=instr(join($r),x)
exit
else
$k=@
for $t = 1 to 4
if 0=instr($c[$-4]+$r[$i]+$q[3-2*($<6)-($i<2)],$t) + $v
$k=$k+$t
endif
next
if 1=($k^)
$o[$-4,$i]=$k
$=7 $i=3
EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#191606 - 2009-01-05 04:04 PM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
WOW! That is efficient, I couldn't even come up with working code, and Drill's code has been Lonked so I doubt there is much left to be golfed.
|
Top
|
|
|
|
#191610 - 2009-01-05 04:51 PM
Re: KiXgolf: Latin Squares - public round
[Re: DrillSergeant]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
I can't believe it! I found 2: 348
Your solution passed all tests
KiXtart
KiXtart Version = 4.60
KiXGolf Script = kixgolf_ls.kix
Computer
OS = Windows Vista Business Edition
CPU = Intel(R) Pentium(R) D CPU 3.20GHz
Speed = 3200 MHz
Memory = 2046 MB
KiXGolf Scoring Engine
Scoring Engine = 3.3
KiXtart Golf Score
Tournament = Latin Squares
Processing Start = 2009/01/05 09:48:23.552
Processing End = 2009/01/05 09:48:23.725
Duration = 0000/00/00 00:00:00.172
KiXGolf Score = 348
Thank you for participating in KiXtart Golf!
Press any key to continue...
Function S($o)
Dim $i, $, $k, $t, $x, $v
For $x = 0 to 16
ReDim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $ = 0 to 7
For $i = 0 to 3
$v = $o[$ mod 4, $i]
If $ < 4
$k = 3-2*($<2)-($i<2)
$r[$i] = $r[$i] + $v
$c[$] = $c[$] + $v
$q[$k] = $q[$k] + $v
$s[$, $i, $x] = $v
Else
; If 0 = InStr(Join($r),x)
If 0 > AScan($r,x,,,1)
Exit
Else
$k = @
For $t = 1 to 4
If 0 = InStr($c[$-4]+$r[$i]+$q[3-2*($<6)-($i<2)],$t) + $v
$k = $k + $t
EndIf
Next
If 1=($k^)
$o[$-4,$i] = $k
$ = 7
$i = 3
; EndIf
; EndIf
; EndIf
; Next
; Next
; Next
EndFunction
|
Top
|
|
|
|
#191651 - 2009-01-06 01:12 AM
Re: KiXgolf: Latin Squares - public round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
RIGHT, 345
; begin KiXgolfUDF
;
;!
Function S($o)
Dim $i, $, $k, $t, $x, $v, $p
For $x = 0 to 16
ReDim $r[3], $c[3], $q[3], $s[3, 3, $x]
For $ = 0 to 7
For $i = 0 to 3
$v = $o[$ mod 4, $i]
$k = 3-2*($<2)-($i<2)
If $ < 4
$r[$i] = $r[$i] + $v
$c[$] = $c[$] + $v
$q[$k] = $q[$k] + $v
$s[$, $i, $x] = $v
Else
If 0 > AScan($r,x,,,1)
Exit
Else
$p = @
For $t = 1 to 4
If 0 = InStr($c[$-4]+$r[$i]+$q[$k-2*($<6)],$t) + $v
$p = $p + $t
EndIf
Next
If 1=($p^)
$o[$-4,$i] = $p
$ = 7
$i = 3
EndFunction
;!
;!
; end KiXgolfUDF
_________________________
!download KiXnet
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 530 anonymous users online.
|
|
|