Skip to content

Instantly share code, notes, and snippets.

@uncompiled
Created March 3, 2018 22:47
Show Gist options
  • Save uncompiled/1a97d7bac32bca3be8f34228ad460113 to your computer and use it in GitHub Desktop.
Save uncompiled/1a97d7bac32bca3be8f34228ad460113 to your computer and use it in GitHub Desktop.
Remove parenthesis
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