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]
got me again! :D
Indeed borrowed the mapping idea from your sol :)
Vectorizing, too easy or too hard?
Is X a Fibonacci Matrix?
Fill a zeros matrix
Who is the smartest MATLAB programmer?
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office