Created
October 7, 2014 00:29
-
-
Save marinuso/9f0e68a6ad15654e0849 to your computer and use it in GitHub Desktop.
Manhattan Amoebas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amoeba←{ | |
idx←,⍳⍴field←' '⍴⍨2/size←⌈4×0.5*⍨(+/!⍳⍵)÷○1 | |
field[G;G←⌈size÷2]←'0' | |
_←{ | |
prevs←idx/⍨,field=⍕⍵-1 | |
⍵∘{ | |
⍵∘{ | |
free←idx/⍨,field=' ' | |
+((⊃free[⍋+/¨|free-⊂⍺])⌷field)←⍕⍵ | |
}¨⍺/⍺ | |
}¨prevs | |
}¨⍳⍵ | |
field | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment