Hard Mode: Basis Palindromes
Mission 2: The Art of Quantum Messages. Part of the Quantum Courier Service, a free course from the Oxford University Quantum Information Society.
A qubit measured in the wrong basis gives a symmetric, useless 50/50 result. As a stand-in puzzle for that kind of basis-symmetry, we're hunting numbers whose binary form reads the same forwards and backwards.
The job: write solve(n) that returns how many integers from 1 to n (inclusive) have a binary representation that's a palindrome.