Skip to content

killrazor/coding_challenge_php

 
 

Repository files navigation

Coway's Game of Life challenge

TODO List

  • thoroughly review tests ✔️

  • run tests - expecting 100% failure ✔️

    • actual Tests: 3, Assertions: 4, Failures: 2.
  • create stubbed methods with documentation ✔️

  • test expecting passes ✔️

  • fill in methods ✔️

    • work on game main game logic ✔️

    • work on changing the window of the board ✔️

    • create additional tests ✔️

  • test using PHP 7.2 ✔️

  • dockerize w/ PHP 5.6 (5.3 isn't available) ✔️

  • test using PHP 5.6 ❗

    • The version of PHPUnit listed in composer.json is for PHP 7.1+
    • Leaving docker items in for reuse later.
  • update documentation ✔️

Explanation

The Game of Life

To run the provided tests, run composer test-gol.

Write some code that evolves generations through the [Conway's game of

life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life). The input will be a game board of cells, either alive (1) or dead

(0).

The code should take this board and create a new board for the

next generation based on the following rules:

  1. Any live cell with fewer than two live neighbors dies (underpopulation)

  2. Any live cell with two or three live neighbors lives on to

the next generation (survival)

  1. Any live cell with more than three live neighbors dies

(overcrowding)

  1. Any dead cell with exactly three live neighbors becomes a

live cell (reproduction)

As an example, this game board as input:


0 1 0 0 0

1 0 0 1 1

1 1 0 0 1

0 1 0 0 0

1 0 0 0 1

Will have a subsequent generation of:


0 0 0 0 0

1 0 1 1 1

1 1 1 1 1

0 1 0 0 0

0 0 0 0 0

Install & Usage

This repository includes a composer.json file which will install PHPUnit. If you don't have composer, you can find instructions on installing it here. It also includes a default phpunit configuration. After running composer install you should be able to run:

  • composer test-gol (Runs tests for all the The Game of Life challenge)

About

i3logix PHP Coding challenge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 94.9%
  • Dockerfile 5.1%