Forum Discussion
Patrick2788
Jan 25, 2024Silver Contributor
Utilizing Excel's turing capabilities to create Conway's 'Game of Life'
The Background It's been said with Lambda (and LET and a wealth of functions in 365) Excel has become 'turing-complete'. To quote the article linked below: "You can now, in principle, write any co...
Patrick2788
Nov 30, 2026Silver Contributor
The new challenge
I thought it might be fun to approach the Game of Life as a 3D challenge where the configuration is supplied as an array of lists. The results remain in lists and are visualized with Python so no flattening is needed.
Input (lists) → Output (lists)
MAKEARRAY has become a very useful function with the support of nested arrays. The indexing is built in and the function is not shape locked. For Life3Dλ, I use it to pick through the configuration layers. It only needs to operate on 1 x k (k = 5 layers).
/* [DEMO] -------------------------------------------------------------------------
Function: Life3Dλ
Author: Patrick H.
Version: 1.0
Dependencies: Mooreλ
Description:
Plots the evolution of a supplied 3D configuration of layers input as an array
of nested lists. Each configuration layer's 3D neighborhood consists of itself
and the previous and next layers.
This function utilizes wrap around logic where the
• first layer's previous layer = last layer
• last layer's next layer = first layer
Parameters:
configuration - an array of nested lists
generations - discrete time checks for evolution of configurations
Notes:
• For best results it's recommended using configurations with at least 5 layers
to avoid symmetrical results where two or more layers share the same 3D
neighborhood.
------------------------------------------------------------------------------*/
Life3Dλ=
LAMBDA(
configuration,
generations,
LET(
// Total configuration layers
k, COUNT(MAP(configuration,SINGLE)),
// Iterations for REDUCE
g, SEQUENCE(generations),
// Determine the fate of each configuration
StepLifeλ,
LAMBDA(a,ballast,
LET(
// Total neighbors - non aggregated 2D
n, MAP(a,Mooreλ),
Fateλ, LAMBDA(
i,j,
LET(
// each configuration (5+ layers potentially)
current_cfg, INDEX(a,1,j),
// wrap around logic for config layers
prev_cfg, IF(j = 1,k,j - 1),
next_cfg, IF(j = k,1,j + 1),
// previous config layer
p, INDEX(n,1,prev_cfg),
// each config layer
q, INDEX(n,1,j),
// next config layer
r, INDEX(n,1,next_cfg),
// remove active cell from total
Total, p + q + r - current_cfg,
// rules
survive?, (current_cfg) *
(Total >= 4) *
(Total <= 6),
revive?, (current_cfg = 0) *
((Total = 4) + (Total = 5)),
outcome, IF(survive?,1,
IF(revive?,1,0)),
outcome)),
next_gen, MAKEARRAY(1,k,Fateλ),
next_gen)),
result, REDUCE(configuration,g,StepLifeλ),
result
));
/* [DEMO] -------------------------------------------------------------------------
Function: Mooreλ
Author: Patrick H.
Version: 1.0
Description:
Designed for use with Conway's Game of Life 3D and called by Life3Dλ.
Calculates the Moore-neighborhood total for every cell in a binary matrix.
The input matrix is padded with a frame of 0s to avoid incomplete
neighborhoods at the boundaries. The center cell is included in the
neighborhood total.
Parameters:
array - Binary 2D matrix.
------------------------------------------------------------------------------*/
Mooreλ=
LAMBDA(
array,
LET(
// Dimensions
h, ROWS(array), w, COLUMNS(array),
// Pad array with frame of 0s
M, FLATTEN({0,0,0;
0,array,0;
0,0,0},0),
// Extract 3x3 neighbor and total. Center value is included.
final, MAKEARRAY(h,w,
LAMBDA(
i,j,
SUM( TAKE(DROP(M,i - 1,j - 1),3,3))) ),
final
));