Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
Last active January 7, 2017 18:07
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 simonewebdesign/0f400700eb2f537c3e1703f4d9b4d700 to your computer and use it in GitHub Desktop.
Save simonewebdesign/0f400700eb2f537c3e1703f4d9b4d700 to your computer and use it in GitHub Desktop.
Game of Life 2D list
# Game of life
# Goal is to have a 2D list that looks like:
[ [false, false, true, false, false],
[true, true, false, false, false],
...
]
# data is a list of coordinates {row, col} where {0,0} is the top-left origin
data = [{0,1}, {2,3}, {3,4}, {4,4}]
# Solution
for i <- 0..4 do
for j <- 0..4 do
a = for {^j, ^i} <- data do
true
end
case a do
[] -> false
[_] -> true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment