My solution to challenge 123 Hard