Best before solution

I listen to music on spotify. Turns out spotify has coding puzzles on their website. While I was busy installing windows on a friend's computer I decided to try one of the puzzles. The puzzle is called best before. You can find the puzzle description here. You can find my solution in python here