Created
March 3, 2018 22:47
-
-
Save uncompiled/1a97d7bac32bca3be8f34228ad460113 to your computer and use it in GitHub Desktop.
Remove parenthesis
This file contains hidden or 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
function gameOfLifeIterator(b) { | |
const a = (x, y) => b[x] && b[x][y] | |
return b.map((r, x) => | |
r.map((_, y) => { | |
let n = 0 | |
a(x - 1, y - 1) && n++ | |
a(x - 1, y) && n++ | |
a(x - 1, y + 1) && n++ | |
a(x, y - 1) && n++ | |
a(x, y + 1) && n++ | |
a(x + 1, y - 1) && n++ | |
a(x + 1, y) && n++ | |
a(x + 1, y + 1) && n++ | |
return (a(x, y) ? n > 1 && n < 4 : n === 3) ? 1 : 0 | |
})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment