Question d’entretien chez Klarna

Write an algorithm to solve this puzzle.