On 4/5/12 I sent out this challenge, and Raul Miller had an encrypted
solution the same day! Here is the translation.
full simulation 0
---------┐
│B goes │
│first , │
│W wins │
+--------+
│.o.o.o.o│
│oWo.o.o.│
│.o.o.o.o│
│o.o.o.o.│
│.o.o.o.o│
│o.o.o.o.│
│.o.o.oBo│
│o.o.o.o.│
+--------+
│.o.o.o.o│
│oWo.o.o.│
│.o.o.o.o│
│o.o.o.o.│
│.o.o.o.B│
│o.o.o.o.│
│.o.o.o.o│
│o.o.o.o.│
+--------+
│.o.o.o.o│
│o.o.o.o.│
│.o.W.o.o│
│o.o.o.o.│
│.o.o.o.B│
│o.o.o.o.│
│.o.o.o.o│
│o.o.o.o.│
+--------+
│.o.o.o.o│
│o.o.o.o.│
│.o.W.o.o│
│o.o.oBo.│
│.o.o.o.o│
│o.o.o.o.│
│.o.o.o.o│
│o.o.o.o.│
+--------+
│.o.o.o.o│
│o.o.o.o.│
│.o.o.o.o│
│o.o.oWo.│
│.o.o.o.o│
│o.o.o.o.│
│.o.o.o.o│
│o.o.o.o.│
L---------
Here is the code in separate lines with no conventional control structures.
SQUARES=:,8 8 {.9 9$'.o'
pieces=: # $ {&(32#'WB')@{.~&2
summary=: ({.,' goes first, ',{:,' wins '"_)@pieces
boards=: (8 8 ,@<@$ ]`[`(SQUARES"_)})"1&(]\~&2) pieces
full=: (]\~&_2)&.;:@summary ; boards
MOVES=:,8 8{.11 11$<@(8#.(#~ */@:<&8"1))"2]11#.inv 120<.(i.121)+/(,-)9 13 21
23 NB. MOVES is a long line
seq=: (, MOVES ({~ ?@#)@{::~ _2&{)^:(~:/@{.~&_2)^:_
simulation=: seq@(|.^:(? bind 2) bind 9 54)
simulation 0
full simulation 0
I have been struggling and finally "translated" MOVES to movesla in
simple J (almost - only 1 @).
K=:11#.inv 120<.(i.121)+/(,-)9 13 21 23
movesla=: 13 :',(x,x){.11 11 $<@((x#.(#~"2(*/"1@:<x"1)))"2)y'
I can't untangle seq.
Raul's solution is impressive and I hope to understand it sometime.
In any case, any help with a way around control structures in the simple J
version.
Linda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm