Conway's Game of Life

From Exercism PythonMITOriginal pagePython1 class period1 exercise8 graded tests

README.md

Conway's Game of Life

Introduction

Conway's Game of Life is a fascinating cellular automaton created by the British mathematician John Horton Conway in 1970.

The game consists of a two-dimensional grid of cells that can either be "alive" or "dead."

After each generation, the cells interact with their eight neighbors via a set of rules, which define the new generation.

Instructions

After each generation, the cells interact with their eight neighbors, which are cells adjacent horizontally, vertically, or diagonally.

The following rules are applied to each cell:

  • Any live cell with two or three live neighbors lives on.
  • Any dead cell with exactly three live neighbors becomes a live cell.
  • All other cells die or stay dead.

Given a matrix of 1s and 0s (corresponding to live and dead cells), apply the rules to each cell, and return the next generation.

Open the 01 folder and edit main.py. Run Tests checks it.

For teachers

Conway's Game of Life

Students solve Exercism's “Conway's Game of Life” Python exercise in CS Room, with Exercism's own tests.

  • Time: 1 class period
  • Tests: 8, set up for you when you import the lesson