{
"id": "061",
"prompt": "Render the rule-90 cellular automaton (the XOR Sierpinski triangle): start row 0 with a single live cell in the middle of a 64-cell row, then each next row is left XOR right of the row above. Recompute the whole thing each frame with two per-frame local arrays (cur/next — arrays are locals in rustlite, which is fine since nothing needs to persist) and cycle the live-cell color with t.",
"solution_rl": "fn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n let cell: i32 = w / 64;\n let rows: i32 = h / cell;\n let mut cur = [0; 64];\n let mut next = [0; 64];\n cur[32] = 1;\n let shade: i32 = 120 + (t / 2) % 100;\n let color: i32 = shade * 256 + 40 + shade * 65536 / 4;\n host::display::clear(0x000000);\n let mut r: i32 = 0;\n while r < rows {\n let mut i: i32 = 0;\n while i < 64 {\n if cur[i] == 1 {\n host::display::fill_rect(i * cell, r * cell, cell, cell, color);\n }\n i = i + 1;\n }\n i = 0;\n while i < 64 {\n let left: i32 = if i == 0 { 0 } else { cur[i - 1] };\n let right: i32 = if i == 63 { 0 } else { cur[i + 1] };\n next[i] = left ^ right;\n i = i + 1;\n }\n i = 0;\n while i < 64 {\n cur[i] = next[i];\n i = i + 1;\n }\n r = r + 1;\n }\n host::display::present();\n}\n",
"tags": [
"grid",
"simulation",
"arrays",
"loops"
]
}