Conway's Game of Life exercise

Could we add an exercise to problem-specifications, where you take a current state of a Game of Life board and output the next?

I think it’s a quite interesting problem and would be a nice addition. There are many different approaches.

I’m not sure about the format - we could use a matrix of ones and zeros, or a multiline string with # and ..

(I’d be happy to contribute this to the problem specifications repo.)

I think it would be better to first implement it for a number of (preferably markedly different) languages, before standardizing the instructions and tests.

I can write solutions in most any of the languages, but I’m not sure if that’s where to start.

I think this could be a nice exercise! Cellular automata are really cool.

We don’t usually go about it this way for new exercises though, as it requires a bit upstream effort.
I’d say, let some other people weigh in and then we can decide if it would be a worthwhile addition.

The reason I suggest implementing it for a few languages first is so that unforeseen avoidable incompatibilities can be discovered.

On reflection I do not really expect any such for this exercise, so I guess going via problem-specifications first should be fine.

It shouldn’t matter much what the representation in problem-specifications is. Individual tracks can parse the canonical data into whatever shape has their preference.

The only thing that I can think of that matters is the suggested function interface. E.g. in Binary Search Tree the problem-specifications make no distinction between empty tree and no tree, which does not match well with languages with algebraic data types such as Rust, Haskell, Gleam.

I like the idea! This gives me strong AoC flashbacks. One approach would be to represent the input and output as a string or list of strings (one per row) using space characters and, say # to represent alive or not. The other input would be the number of rounds to simulate.

You can start by copying another exercise in the problem specs and modifying all the files.

Is it ok if I create a PR to add this to Python for a start?

No, thank you. :slightly_smiling_face:

The Python track has a pause right now on creating new practice exercises. We’ve got other things that need to get done first.

@Steffan153 I’m sure C# and F# would welcome it as a starting point :slight_smile:

Thanks, I’ll try to work on something for F# :slightly_smiling_face:

What about JS? There have been several new exercises for it lately.

1 Like

Yep. I think @SleeplessByte would have appreciate that too :slight_smile:

Here’s a PR for C# as well :slightly_smiling_face:

1 Like

I’m pretty sure the Java track could appreciate this exercise as well. Here’s the GitHub issue in case anyone is interested in implementing it: game-of-life: implement practice exercise · Issue #2790 · exercism/java · GitHub

1 Like