{
"id": "197",
"prompt": "A fake system monitor with four meters - CPU, MEM, NET, DSK: each value 0..100 does its own clamped random walk in a state slot (one shared LCG seed slot), drawn as a horizontal bar with a white peak-hold marker that only decays 1 unit every 10 frames, plus the live number at the row's end.",
"solution_rl": "fn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n if host::display::state_get(0) == 0 {\n host::display::state_set(0, 1);\n host::display::state_set(9, 11);\n let mut k: i32 = 0;\n while k < 4 {\n host::display::state_set(1 + k, 50);\n host::display::state_set(5 + k, 50);\n k = k + 1;\n }\n }\n host::display::clear(0x0a0a0e);\n host::display::draw_string(16, 12, \"SYSTEM MONITOR\", 0x808080, 1);\n host::display::draw_string(16, 44, \"CPU\", 0xc0c0c0, 2);\n host::display::draw_string(16, 114, \"MEM\", 0xc0c0c0, 2);\n host::display::draw_string(16, 184, \"NET\", 0xc0c0c0, 2);\n host::display::draw_string(16, 254, \"DSK\", 0xc0c0c0, 2);\n let bx: i32 = 70;\n let bw: i32 = w - bx - 60;\n let mut i: i32 = 0;\n while i < 4 {\n let seed: i32 = host::display::state_get(9) * 1103515245 + 12345;\n host::display::state_set(9, seed);\n let mut v: i32 = host::display::state_get(1 + i) + ((seed >> 16) & 15) - 7;\n if v < 0 { v = 0; }\n if v > 100 { v = 100; }\n host::display::state_set(1 + i, v);\n let mut pk: i32 = host::display::state_get(5 + i);\n if v > pk { pk = v; }\n if t % 10 == 0 && pk > v { pk = pk - 1; }\n host::display::state_set(5 + i, pk);\n let y: i32 = 40 + i * 70;\n host::display::fill_rect(bx, y, bw, 24, 0x1c1c24);\n host::display::fill_rect(bx, y, v * bw / 100, 24, 0x40a0e0);\n host::display::fill_rect(bx + pk * bw / 100, y - 2, 2, 28, 0xffffff);\n host::display::draw_number(bx + bw + 10, y + 4, v, 0xc0c0c0, 2);\n i = i + 1;\n }\n host::display::present();\n}\n",
"tags": [
"gauge",
"prng",
"state"
]
}