Level 5Program correctnessWrite a program
Count the 1 bits
Read n and output how many of its 8 bits are 1 (so 0 → 0, 255 → 8, 22 → 3). Bench-8 has no shift instruction: masks with AND are your friend.
Public tests
- input 0 → 0
- input 255 → 8
- input 22 → 3
- input 128 → 1
- input 85 → 4
Scored on correctness: every test must pass. Skills: bit masks, unrolling.
New to this? Silicon Studio 11: Arithmetic logic unit
How results are computed: model assumptions.
One instruction per line. Labels end with a colon, comments start with a semicolon. Numbers can be 12, 0x0C or 0b1100.