Elementary cellular automaton
Created on Jan. 19, 2017
by Julien Palard
Build a program taking an integer as single parameter, .
This integer is a rule number in the Wolfram
code.
Your program will display a 79×40 table filled with #
for ones (1
s) and .
for zeroes (0
s), as a result of running an elementary
automata for
the given rule number (the int
parameter).
The first line will always be filled with zeroes except for a single
cell with a 1 right in the middle.
The "board" is a cylinder: on the left of the leftmost column is the rightmost
column, and vice-versa.
Here is an example, so you can check your implementation visually:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 | julien@prof$ python solution.py 90
.......................................#.......................................
......................................#.#......................................
.....................................#...#.....................................
....................................#.#.#.#....................................
...................................#.......#...................................
..................................#.#.....#.#..................................
.................................#...#...#...#.................................
................................#.#.#.#.#.#.#.#................................
...............................#...............#...............................
..............................#.#.............#.#..............................
.............................#...#...........#...#.............................
............................#.#.#.#.........#.#.#.#............................
...........................#.......#.......#.......#...........................
..........................#.#.....#.#.....#.#.....#.#..........................
.........................#...#...#...#...#...#...#...#.........................
........................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#........................
.......................#...............................#.......................
......................#.#.............................#.#......................
.....................#...#...........................#...#.....................
....................#.#.#.#.........................#.#.#.#....................
...................#.......#.......................#.......#...................
..................#.#.....#.#.....................#.#.....#.#..................
.................#...#...#...#...................#...#...#...#.................
................#.#.#.#.#.#.#.#.................#.#.#.#.#.#.#.#................
...............#...............#...............#...............#...............
..............#.#.............#.#.............#.#.............#.#..............
.............#...#...........#...#...........#...#...........#...#.............
............#.#.#.#.........#.#.#.#.........#.#.#.#.........#.#.#.#............
...........#.......#.......#.......#.......#.......#.......#.......#...........
..........#.#.....#.#.....#.#.....#.#.....#.#.....#.#.....#.#.....#.#..........
.........#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#.........
........#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#........
.......#...............................................................#.......
......#.#.............................................................#.#......
.....#...#...........................................................#...#.....
....#.#.#.#.........................................................#.#.#.#....
...#.......#.......................................................#.......#...
..#.#.....#.#.....................................................#.#.....#.#..
.#...#...#...#...................................................#...#...#...#.
#.#.#.#.#.#.#.#.................................................#.#.#.#.#.#.#.#
|
Don't forget to print something friendly if the human forgot to give
the rule number as a parameter of your program.