Week 12: Optional Exercises

1. Consider the following game. There is a row of N squares, each containing some positive integer. A button begins on the leftmost square. On each player's turn, they can move the button right either (a) one square or (b) by k squares, where k is the number currently under the button. The winner is the player who first moves the button past the rightmost square. Write a method that takes an array containing the numbers on the board, and returns a boolean which is true if the first player can always win.