Forum Discussion
Utilizing Excel's turing capabilities to create Conway's 'Game of Life'
I too had a one-step success, followed by failure. I started by just exploring a single step of the process and came up with
Stepλ
"Calculates outturn for a single cell"
= LET(
count, SUM(OFFSET(cell, -1, -1, 3, 3)) - cell,
IF(cell, SUM(SIGN(count = {2, 3})), SIGN(count = 3))
)
For the entire board
= MAP(start, Stepλ)
worked fine but
= REDUCE(start, SEQUENCE(2), LAMBDA(board,k, MAP(board, Stepλ)))
failed because OFFSET is a range operator and, at step 2, I was offering it an array. Back to the drawing board! I would probably stick with REDUCE but it is back to the start with OFFSET.
At the moment I see myself as going with MAKEARRAY in order to generate indices and
= SUM(INDEX(start,r+δr,c+δc)) - INDEX(start,r,c)
δr = {1;0;-1}
δc = {1,0,-1}
Still some edge conditions to sort, though.
The big problem I encounterd with INDEX (and why you see my odd CHOOSECOLS-CHOOSEROWS concoction) is what happens when 'r' and/or 'c' is 0. I'd rather have INDEX fail in such a scenario so I went with the two nested functions. TAKE/DROP seem to make sense but were slowly eating the board on each iteration.