Simple solution that seems to work fine
Test to check that the solution is correcy