Codility Turtle Crossing problem