Solution for the day 2 problem