June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -4,20 +4,20 @@ define size = 100
|
|||
enum |White, Black|
|
||||
var plane = size.of { size.of (White) }
|
||||
|
||||
var (x, y) = @|([size/2 -> int]*2)
|
||||
var (x, y) = ([size >> 1] * 2)...
|
||||
var dir = dirs.len.irand
|
||||
|
||||
var moves = 0
|
||||
loop {
|
||||
(x >= 0) && (y >= 0) && (x < size) && (y < size) || break
|
||||
|
||||
given(plane[x][y]) {
|
||||
given (plane[x][y]) {
|
||||
when (White) { dir--; plane[x][y] = Black }
|
||||
when (Black) { dir++; plane[x][y] = White }
|
||||
}
|
||||
|
||||
++moves
|
||||
[\x, \y]:dirs[dir %= dirs.len] -> each {|a,b| *a += b }
|
||||
[[\x, \y], dirs[dir %= dirs.len]].zip {|a,b| *a += b }
|
||||
}
|
||||
|
||||
say "Out of bounds after #{moves} moves at (#{x}, #{y})"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue