Problem 42877. Cellular Automaton | Rule X
Cellular Automata (CA) provide a convenient way to represent many kinds of systems in which the values of cells (either 0 or 1) in an array are updated in discrete steps according to a local rule.
Start with a single ONE at the center of the 1st row of an (n+1)-by-(2*n+1) sheet of ZEROs , the value of each point in the array at position A(i,j) , i = 2:n is determined by values of its 3-neighbors A(i-1, j-1), A(i-1,j), A(i-1,j+1) according to the given Rule.
Since we consider 3-neighbors, they can have one of 8 possible states (starting with 000 to 111). The Rule number is a decimal number between 1-256 (i.e. 2^8), where its 8-bit Bin form represents the outputs of those 8 possible states as shown in the figure below.
You problem is to generate the Cellular Automaton array given the Rule number and number of iteration to run (n = rows of array).
NOTE: you can plot the result using imagesc(CA) for fun.
\
/
Solution Stats
Problem Comments
-
5 Comments
It seems that the reference answer in the test suite is incorrect. Taking test case 1 (rule 30) as an example, the first and last elements in the 4th row should be 1, according to the figure you posted for rule 30 in your problem description.
Peng is right. It looks like we are supposed to ignore leftmost and rightmost columns due to the fact those cells have access to only two cells above, but it is not mentioned in the description as well as shown example stands in opposite to that assumption.
Thanks for your clarification, Jan. In this case, it is necessary that the assumption is stated in the problem, or the answer should stick to the example shown in the description.
BTW. Illustraton from mathworld.worfram.com is missing reference, isn't it?
The example does not match the solutions. First puzzle(30,3) has [0 1 1 0 ...] as next to last row with an expected [0 1 0]. The example shows this as [1 1 0]
Solution Comments
Show commentsProblem Recent Solvers17
Suggested Problems
-
396 Solvers
-
Determine if input is a Narcissistic number
197 Solvers
-
Given a matrix, return the last eigen value
221 Solvers
-
When can one be the Life Member of the IEEE?
74 Solvers
-
537 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!