{
"id": "260",
"prompt": "A physics-class split-screen: drop one ball in vacuum on the left and an identical ball with linear air drag on the right at the same instant. Both gain 6 per frame; the right one also loses v/16, so it visibly settles at terminal velocity around 12px/frame while the left keeps accelerating. Print each ball's live speed, add faint altitude ticks, stop each ball at the floor, and once both are down pause briefly and re-drop forever. State slots hold both y/v pairs plus the pause countdown.",
"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(1, 320);\n host::display::state_set(2, 0);\n host::display::state_set(3, 320);\n host::display::state_set(4, 0);\n host::display::state_set(5, 0);\n }\n let mut ya: i32 = host::display::state_get(1);\n let mut va: i32 = host::display::state_get(2);\n let mut yb: i32 = host::display::state_get(3);\n let mut vb: i32 = host::display::state_get(4);\n let mut pause: i32 = host::display::state_get(5);\n let floor: i32 = (h - 30) * 8;\n if pause > 0 {\n pause = pause - 1;\n if pause == 0 {\n ya = 320;\n va = 0;\n yb = 320;\n vb = 0;\n }\n } else {\n va = va + 6;\n vb = vb + 6 - vb / 16;\n ya = ya + va;\n yb = yb + vb;\n if ya > floor { ya = floor; va = 0; }\n if yb > floor { yb = floor; vb = 0; }\n if ya == floor && yb == floor {\n pause = 50;\n }\n }\n host::display::state_set(1, ya);\n host::display::state_set(2, va);\n host::display::state_set(3, yb);\n host::display::state_set(4, vb);\n host::display::state_set(5, pause);\n host::display::clear(0x0c0c10);\n host::display::fill_rect(w / 2 - 1, 0, 2, h, 0x242430);\n let mut gy: i32 = 40;\n while gy < h - 20 {\n host::display::fill_rect(0, gy, 8, 1, 0x303040);\n host::display::fill_rect(w - 8, gy, 8, 1, 0x303040);\n gy = gy + 60;\n }\n host::display::fill_rect(0, h - 22, w, 4, 0x404048);\n host::display::fill_rect(w / 4 - 10, ya / 8, 20, 20, 0xf0f0f0);\n host::display::fill_rect(w * 3 / 4 - 10, yb / 8, 20, 20, 0x40c0d0);\n host::display::draw_string(w / 4 - 40, 8, \"VACUUM\", 0x808080, 1);\n host::display::draw_number(w / 4 + 30, 8, va / 8, 0xffffff, 1);\n host::display::draw_string(w * 3 / 4 - 30, 8, \"DRAG\", 0x808080, 1);\n host::display::draw_number(w * 3 / 4 + 30, 8, vb / 8, 0xffffff, 1);\n host::display::present();\n}\n",
"tags": [
"simulation",
"physics",
"state",
"comparison"
]
}