{
"id": "046",
"prompt": "Deterministic PRNG LIBRARY: export next(seed) (one LCG+xorshift step, always non-negative), pick(seed, lo, hi) (bounded to lo..=hi), and mix(a, b) (combine two seeds). dims() + a frame() landing card that also proves the generator by scattering 32 pick()-placed pixels.",
"solution_rl": "fn next(seed: i32) -> i32 {\n let mut h: i32 = seed * 1103515245 + 12345;\n h = (h >> 13) ^ h;\n if h < 0 { h = 0 - h; }\n h\n}\n\nfn pick(seed: i32, lo: i32, hi: i32) -> i32 {\n lo + next(seed) % (hi - lo + 1)\n}\n\nfn mix(a: i32, b: i32) -> i32 {\n next(a * 31 + b)\n}\n\nfn dims() -> i32 {\n (256 << 16) | 128\n}\n\nfn frame(t: i32) {\n host::display::clear(0x000000);\n host::display::draw_string(8, 8, \"LIB PRNG\", 0xffffff, 2);\n host::display::draw_string(8, 30, \"NEXT PICK MIX\", 0x00ff66, 1);\n let mut i: i32 = 0;\n while i < 32 {\n host::display::set_pixel(pick(i * 2, 8, 248), pick(i * 2 + 1, 48, 120), 0xffff00);\n i = i + 1;\n }\n host::display::present();\n}\n",
"tags": [
"library",
"prng",
"functions"
]
}