Skip to content

Instantly share code, notes, and snippets.

@marinuso
Created October 7, 2014 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marinuso/9f0e68a6ad15654e0849 to your computer and use it in GitHub Desktop.
Save marinuso/9f0e68a6ad15654e0849 to your computer and use it in GitHub Desktop.
Manhattan Amoebas
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