The audience was stunned when contestant Michael Larson won $110.237 on Press Your Luck in 1984. Easily the largest one-day total ever won on a game show to that date. As lights flashed randomly on the Big Board — the name given to the eighteen-square gameboard used in the show — somehow Larson was consistently able to stop on squares that led to cash and additional play, and avoid the "whammy" that would bankrupt him.

Paul Michael Larson
Paul Michael Larson

It turned out that the light indicator wasn't random. In studying the game at home, Larson had discovered that it followed five recognizable patterns. After memorizing these he could always be sure of landing on winning squares.

CBS producers divined the scheme, but they could find no cause to disqualify Larson, as he had broken no rules. They paid him his money, fixed the board, and established a maximum sum that future contestants could win. Larson may have congratulated himself, but he didn't get to enjoy his winnings — he lost the money in bad real estate investments and died of throat cancer at age 49.

Assignment

Below is an example configuration of the Big Board, the gameboard used in the television show Press Your Luck. The board consisted of $$p$$ squares (in the example $$p = 18$$) arranged in a rectangle, each of which displayed one of $$s$$ screens (in the example $$s = 3$$). If a player took turn, a fast cycle was initiated where at each step all squares displayed the next screen and a random square lit up. The player could stop the cycle by hitting his buzzer, which either won him the price that was shown on the screen marked by the randomizer light or made him loose al his money if he hit a screen marked with the whammy.

Big Board
Configuration of the Big Board, the game board that was used in the television show Press Your Luck. The board is composed of 18 square, with each square showing one of three screens in turn. The "+S" denotes screens that award contestants an additional spin, a feature critical to allowing Larson to go on his run.

However, Larson had discovered a certain regularity in the apparently random behaviour of the gameboard. Each cycle turned out to be completely determined by a pattern that was composed of a sequence of positive integers and a square that was lit at the start of the cycle. At each step in the cycle, the gameboard is modified in two ways, that work completely independent of each other:

The above figure illustrates this procedure with a cycle that uses the pattern [1, 3, 7] and starts at the square in the top left-hand of the gameboard. At the start of the cycle, the square in the top left-hand of the gameboard displays the screen containing $1750, the square to the right displays the screen containing $500, and so on. In the first step the randomizer light moves ahead 1 square clockwise through the rectangular board, and each square displays its second screen. If we would hit the buzzer at this point in time, the screen containing $1250 would be lit. In the second stap the randomizer light moves ahead 3 squares clockwise through the rectangular board, and the third screen containing whammy is lit. In the next step the randomizer light moves ahead 7 squares clockwise through the rectangular board, and the first screen displaying $500 is lit (during the previous step, each square displayed the last of its three screens). In the next step the randomizer light again moves ahead 1 square clockwise through the rectangular board (after the last integer from the pattern has been used, we continue with the first integer), and the second screen containing $2500 is lit. The figure continues to show the next two steps from the cycle. Your task:

Both functions must raise an AssertionError with the message invalid board, in case the number of prices in the given sequence of strings is not a multiple of $$s$$.

Example

>>> prices = ('$100', '$200', '$300', '$400', '$500', '$600', '$700', '$800', '$900', '$1000', 'whammy', '$1100', '$1200', '$1300', '$1400', '$1500')

>>> board(prices)
[['$100'], ['$200'], ['$300'], ['$400'], ['$500'], ['$600'], ['$700'], ['$800'], ['$900'], ['$1000'], ['whammy'], ['$1100'], ['$1200'], ['$1300'], ['$1400'], ['$1500']]
>>> board(prices, screens=2)
[['$100', '$200'], ['$300', '$400'], ['$500', '$600'], ['$700', '$800'], ['$900', '$1000'], ['whammy', '$1100'], ['$1200', '$1300'], ['$1400', '$1500']]
>>> board(prices, screens=4)
[['$100', '$200', '$300', '$400'], ['$500', '$600', '$700', '$800'], ['$900', '$1000', 'whammy', '$1100'], ['$1200', '$1300', '$1400', '$1500']]
>>> board(prices, screens=3)
Traceback (most recent call last):
AssertionError: invalid board

>>> price(pattern=[1, 3, 7], steps=1, prices=prices, screens=2)
'$400'
>>> price(pattern=[1, 3, 7], steps=2, prices=prices, screens=2, start=1)
'whammy'
>>> price(pattern=[5, 2, 9, 3], steps=20, prices=prices, screens=4, start=4)
'$1200'