daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function gameOfLifeIterator(b) {
  2.   const a = (x, y) => b[x] && b[x][y]
  3.   return b.map((r, x) =>
  4.     r.map((_, y) => {
  5.       let n = 0
  6.       a(x - 1, y - 1) && n++
  7.       a(x - 1, y) && n++
  8.       a(x - 1, y + 1) && n++
  9.       a(x, y - 1) && n++
  10.       a(x, y + 1) && n++
  11.       a(x + 1, y - 1) && n++
  12.       a(x + 1, y) && n++
  13.       a(x + 1, y + 1) && n++
  14.       return (a(x, y) ? n > 1 && n < 4 : n === 3) ? 1 : 0
  15.     }))
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top