{
"id": "193",
"prompt": "Demonstrate smoothing on one chart with zero state slots: 40 noisy samples from an LCG hash of the index drawn as gray dots, overlaid by the 4-sample trailing moving average as a connected bright line (recompute the hash values as needed - they are deterministic), labeled RAW and SMOOTH.",
"solution_rl": "fn hv(i: i32) -> i32 {\n let s: i32 = i * 1103515245 + 12345;\n ((s >> 16) & 32767) % 80 + 10\n}\n\nfn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n host::display::clear(0x0a0a0a);\n let base: i32 = h - 60;\n let mut i: i32 = 0;\n while i < 40 {\n let x: i32 = 8 + i * (w - 16) / 39;\n let y: i32 = base - hv(i) * 3;\n host::display::fill_rect(x - 1, y - 1, 3, 3, 0x707070);\n i = i + 1;\n }\n i = 4;\n while i < 40 {\n let a0: i32 = (hv(i - 4) + hv(i - 3) + hv(i - 2) + hv(i - 1)) / 4;\n let a1: i32 = (hv(i - 3) + hv(i - 2) + hv(i - 1) + hv(i)) / 4;\n let x0: i32 = 8 + (i - 1) * (w - 16) / 39;\n let x1: i32 = 8 + i * (w - 16) / 39;\n host::display::draw_line(x0, base - a0 * 3, x1, base - a1 * 3, 0x00d0ff);\n i = i + 1;\n }\n host::display::draw_string(8, 8, \"RAW\", 0x707070, 2);\n host::display::draw_string(70, 8, \"SMOOTH\", 0x00d0ff, 2);\n host::display::present();\n}\n",
"tags": [
"chart",
"prng",
"math"
]
}