2015-16 Woburn Challenge Finals - Senior Division
After
Now, the cows had really become quite content with their Scarberian lives, free to eat their feed on farmer Daniel MacDonald's farm in peace. However, they weren't about to be taken by surprise by this turn of events. As everyone knows, all cows possess a geomagnetic sixth sense, which historically guided their ancestors during migrations. One day, while Bo Vine was out chewing his cud, his particularly potent sixth sense picked up on something rather peculiar. Detecting a disturbance in the electromagnetic field surrounding the Sacred Farm, Bo Vine swiftly realized that the monkeys' long overdue counterattack was imminent! As fast as he could, he rushed back to the barn, where the lethargic farmer had been nibbling a stalk of wheat. Standing before him, Bo Vine let out a thunderous bellow which could be heard throughout the entire countryside – "Dang, Daniel! The monkeys are back at it again with the bright plans!"
However bright these plans are, the Head-Monkey knows that victory will require a great deal of money to purchase supplies and ammunition. Alas, the monkeys have been in hiding for so many years that they were never able to find jobs and make money. To make up for this financial deficit, the Head-Monkey has decided to run a business on the side. Unfortunately, the monkeys do not possess many belongings that are in demand by the market… except for one – monkey fur is one of the most luxurious and prized materials in the fashion industry! The smooth, silky locks of any monkey's fur are in high demand by the world's finest coat designers and couturiers. In a stroke of genius, the Head-Monkey ordered all of her subordinates to shave off the fuzz on their bodies and donate it to the business. Before long, sales seemed to be booming – and yet, there were still some problems.
Monkeys aren't particularly renowned for their arithmetic. As sales
grew, accounting errors were slipping through the cracks, resulting in
unnecessary losses to their income. To practice their division skills,
the Head-Monkey proposed that her accountants play the classic game of
FizzBuzz. In FizzBuzz, players sit around in a circle and take turns
counting incrementally, replacing any number divisible by three with the
word fizz
, and any number divisible by five with the word buzz
.
Numbers divisible by both three and five are replaced with fizzbuzz
.
The game ends once a player misspeaks or once they hit
1
, 2
, fizz
, 4
, buzz
, fizz
, 7
, 8
, fizz
, buzz
, 11
, fizz
, 13
, 14
, fizzbuzz
, 16
Monkeys aren't particularly renowned for their articulateness. When the
game gets long, no monkey is a fan of saying "…, five thousand seven
hundred and ninety two, fizz, five thousand seven hundred and ninety
four, buzz, …". Thus, the Head-Monkey invented her own variation of the
game – FizzBuzzOok – which is streamlined for primates. The rules of
FizzBuzzOok are almost identical to FizzBuzz, except that whenever a
number is supposed to be said in FizzBuzz, the player should instead say
ook
. As such, a perfect game of FizzBuzzOok where
ook
, ook
, fizz
, ook
, buzz
, fizz
, ook
, ook
, fizz
, buzz
, ook
, fizz
, ook
,
ook
, fizzbuzz
, ook
Monkeys aren't particularly renowned for their memory. Sometimes, games
of FizzBuzzOok would have to be paused as the monkeys went on banana
breaks. When they returned, they would quickly lose track of where they
had stopped! However, they would be able to remember what their desired
goal of ook
, fizz
, ook
". In this case, there are
two possible positions at which they could have paused – after either
turn
Given a sequence of words representing the past
In test cases worth
Input Specification
The first line of input consists of two space-separated integers
ook
, fizz
, buzz
, or fizzbuzz
(for
Output Specification
Output a single integer – the number of possible positions that the game
could have been paused at, or 0
if the given sequence of turns will
never occur in a game of FizzBuzzOok up to
Sample Input 1
16 3
ook
fizz
ook
Sample Output 1
2
Sample Input 2
16 3
ook
buzz
fizzbuzz
Sample Output 2
0
Comments