Jump to content

Elementary cellular automaton/Random number generator: Difference between revisions

changing requirement so that the state space warps
(rephrasing)
(changing requirement so that the state space warps)
Line 1:
{{draft task}}
 
EDIT: The requirements of this task have recently been slightly modified. Please update your solution if necessary.
 
[[wp:Rule 30|Rule 30]] is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the [[wp:Mathematica|Mathematica]] software for its default random number generator.
 
Line 6 ⟶ 9:
The purpose of this task is to demonstrate this. With the code written in the [[Elementary cellular automaton|parent task]], which you don't need to re-write here, show the ten first bytes that emerge from this recommendation. To be precise, you will start with a state of all cells but one equal to zero, and you'll follow the evolution of the particular cell whose state was initially one. Then you'll regroup those bits by packets of eight, reconstituting bytes with the first bit being the [[wp:most significant bit|most significant]].
 
The number of cells should be a finite, reasonably large number of your choice. The cells must warp on boundaries: this means that the right-most cell is considered as the left neighbor of the left-most cell, and reciprocally.
You can pick which ever length you want for the initial array but it should be visible in the code so that your output can be reproduced with an other language.
 
For extra-credits, you will make this algorithm run as fast as possible in your language, for instance with an extensive use of bitwise logic.
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.