https://www.codingame.com/training/medium/don%2527t-panic-episode-1/solution