Hard Mode: Bit Census
Mission 0: The Information Problem. Part of the Quantum Courier Service, a free course from the Oxford University Quantum Information Society.
Fancy some real fieldwork, Agent? Forget multiple choice. This one's graded by actually running your code.
The job: write solve(n) that returns the total number of 1 bits across the binary representations of every integer from 1 to n inclusive. Add up the bits in 1, 10, 11, 100, ... all the way to n, and hand back the grand total.
No imports needed beyond the standard library. bin(i).count('1') is fair game. The tests stop at n = 100, so a straightforward loop will clear them — but see whether you can find the shortcut that would still work at n = 10⁷, because that is the version a courier would actually ship.