{
"id": "185",
"prompt": "A donut chart of three shares A 45 / B 30 / C 25 percent: 32 blocks around a ring, each colored by which cumulative share its position falls into (block i covers percent i*100/32), leaving the center hollow, with a swatch legend showing each label and value.",
"solution_rl": "fn sv(i: i32) -> i32 {\n let tab = [0, 25, 49, 71, 90, 106, 117, 124, 127, 124, 117, 106, 90, 71, 49, 25, 0, -25, -49, -71, -90, -106, -117, -124, -127, -124, -117, -106, -90, -71, -49, -25];\n tab[i & 31]\n}\n\nfn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n let cx: i32 = w / 2;\n let cy: i32 = h / 2 - 20;\n let r: i32 = if w < h { w / 3 } else { h / 3 };\n host::display::clear(0x0a0a0e);\n let mut i: i32 = 0;\n while i < 32 {\n let p: i32 = i * 100 / 32;\n let col: i32 = if p < 45 { 0x40b0ff } else { if p < 75 { 0xffb040 } else { 0x60d080 } };\n let x: i32 = cx + sv(i) * r / 127;\n let y: i32 = cy - sv(i + 8) * r / 127;\n host::display::fill_rect(x - 8, y - 8, 17, 17, col);\n i = i + 1;\n }\n let ly: i32 = h - 70;\n host::display::fill_rect(20, ly, 12, 12, 0x40b0ff);\n host::display::draw_string(38, ly, \"A\", 0xc0c0c0, 2);\n host::display::draw_number(58, ly, 45, 0xc0c0c0, 2);\n host::display::fill_rect(110, ly, 12, 12, 0xffb040);\n host::display::draw_string(128, ly, \"B\", 0xc0c0c0, 2);\n host::display::draw_number(148, ly, 30, 0xc0c0c0, 2);\n host::display::fill_rect(200, ly, 12, 12, 0x60d080);\n host::display::draw_string(218, ly, \"C\", 0xc0c0c0, 2);\n host::display::draw_number(238, ly, 25, 0xc0c0c0, 2);\n host::display::present();\n}\n",
"tags": [
"chart",
"trig-table",
"loops"
]
}