Created
December 2, 2013 23:58
-
-
Save fallengiants/7761369 to your computer and use it in GitHub Desktop.
Rule 110
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rule110 = [0, 1, 1, 1, 0, 1, 1, 0] | |
| iterate = (array_of_bools) -> | |
| result_array = [] | |
| array_of_bools = [false, false, array_of_bools..., false, false] | |
| for index_pointer in [0..(array_of_bools.length - 2)] | |
| tally = 0 | |
| tally += 1 << i for i in [0..2] when array_of_bools[index_pointer + 2 - i] | |
| result_array.push rule110[tally] | |
| result_array.slice(0, -2) | |
| iterations = 50 | |
| starter = [1] | |
| dump = (ary) -> | |
| out = ary.join('') | |
| ln = iterations + 1 - ary.length | |
| if ln > 0 | |
| out = " #{out}" for i in [1..ln] | |
| console.log out | |
| dump starter | |
| for row_number in [1..iterations] | |
| starter = iterate(starter) | |
| dump starter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment