Spotify’s programming puzzles

I recently came across some programming puzzles that Spotify have put out there for developers to test their skills on. There are 3 puzzles that range from easy to hard (or Reggae, Funk and Heavy metal as Spotify put it).

I had a go at the first challenge, titled ‘bestbefore‘ where your program should accept a date but without knowing whether the first, second or third parts are the day, month or year. Your challenge is to find the earliest legal date between 2000 and 2999.

The programs have to be written in C, C++, Java or Python. As my experience mainly lies in PHP I had to pick one of these other languages to code it in. One of my personal challenges this year is to learn Python so what better opportunity to apply it to a problem like this one.

Here is my solution to the ‘bestbefore’ problem. If you want to have  a go at the challenges yourself, you might want to close your eyes now!

I fully accept that this is not going to be the most beautiful Python code you’ve ever read nor a very elegant solution, but it seems to work and I’m very proud of my first decent length Python program…

4 thoughts on “Spotify’s programming puzzles

  1. mmm, permutations, that would have been useful. Difficult to know what to look for with Python. I don’t find the documentation as useful as PHPs’s.

    Lots to learn I have…

  2. Also, apologies for the code formatting. It seems that the plugin I’m using doesn’t always understand what a line break is :P

Leave a Reply