Living Museum of Learning

Small circles, Big thinkers 🌱
Ethan Reused His Own Thinking

Ethan Reused His Own Thinking

A hint about function order led to a deeper idea: yesterday's work can solve today's problem

Ethan had already written a function called copy1DArray().

Now he needed to copy an entire two-dimensional world for Conway's Game of Life.

His first solution worked, but it duplicated all of the copying logic inside a new function.

Meanwhile, his simulation still behaved strangely. A pre-beehive pattern gradually lost its symmetry, which made no sense to him.

Something important was missing.

Ethan made a copy of his original copy2DArray() and began improving it.

He commented out the top copy.

I said:

"Comment out the top one."

Then I added:

"What I said is actually a hint."

He paused.

A few minutes later, I explained:

"Function definitions can go anywhere. I want you to see your copy1DArray() below it."

He continued thinking.

Finally, I circled the inner loop.

"Can we reuse your hard work in copy1DArray()?"

Suddenly, everything clicked.

Ethan immediately rewrote:

copy.push(copy1DArray(twoDArr[r]));

His earlier work became a building block.

Moments later he returned to an old line:

let w = world;

and changed it to:

let w = copy2DArray(world);

The pre-beehive suddenly evolved symmetrically.

He shouted:

"Wow, now it works! The copy of the world!"

The bug had not been in the Game of Life rules.

The bug had been in the idea of state itself.

A few minutes later, after adding one missing rule, the beehive appeared.

Then a blinker oscillated forever.

For the first time, Ethan watched a pattern live indefinitely.

Ethan experienced several important ideas in a single class:

functions can build on other functions
previous work can be reused
current state and future state must remain separate
simple rules can create living behavior

Perhaps most importantly, he discovered that his own earlier thinking could become a tool.

The function he wrote previously was no longer an exercise.

It became part of a larger system.