Some time ago I came across Spotify puzzles, a set of CS problems that Spotify’s engineers published for interested developers to solve. What made the format interesting was the submission mechanism: you email your solution, and an automated judge tests it and sends back results. No web form, no leaderboard. Just a clean feedback loop.
Updated 2026: Spotify’s puzzle site has been offline for several years. The problems and some community solutions are preserved on the Wayback Machine.
Let’s start with the first problem, sorted by difficulty:
Your task will be to write a program for reversing numbers in binary. For instance, the binary representation of 13 is 1101, and reversing it gives 1011, which corresponds to the number 11.
Straightforward enough. The puzzle specified C, C++, Java, or Python 2.6 as valid languages. I chose Python and took the opportunity to set up PyCharm, which the Python community consistently recommends. It’s built on the IntelliJ platform (familiar territory if you’ve used IntelliJ IDEA or Eclipse), and the code suggestions and refactoring tools make a real difference even on small problems.
The binary reversal itself is simple: convert to binary, reverse the string, convert back to decimal. The main thing to be careful about is the edge case: what happens with leading zeros after reversal? The problem statement clarifies that leading zeros are dropped, so 1100 reversed is 11 (3), not 0011 (3 with leading zeros; same value, but the representation matters for parsing).
I also used this as an excuse to try pytest instead of my usual Nose.
Updated 2026: Nose has been deprecated since 2015 and is no longer maintained. pytest is now the de facto standard for Python testing, and has been for years. If you’re still using unittest or Nose, switch to pytest.
pytest turned out to be cleaner and more readable than I expected: assertions are just plain Python assert statements, exception testing is natural, and there’s no boilerplate. I’ve been using it ever since.
All code is in the spotify_puzzles repository on GitHub. Stay tuned for round two!