Problem p00221 - Generation 2

Orig Description

FizzBuzz
There is a game that uses numbers called "Fizz Buzz". This game is played by multiple players who count up numbers from 1 in turn, and each player says only one number that the previous player said. At that time, if it is divisible by 3, say "Fizz", if it is divisible by 5, say "Buzz", and if it is divisible by both, say "FizzBuzz" instead of the number. For example, the first 16 statements are as follows.
    1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, ...
  Taro decided to play "Fizz Buzz" with his friends. Taro and his friends decided on the following rule. 
  "The person who made a mistake drops out. The next person starts from the number after the wrong number. That is, if you say 1, 2, 3, you made a mistake with 3, so you start with 4 next." 
They play the game according to this rule, but because they are not used to the game, they may not notice their mistakes and cannot make a fair judgment. So you decided to create a program that outputs the remaining players at the end of the designated number of statements so that Taro and his friends can enjoy this game.
  Create a program that takes the number of players and the number of statements made during the game as input, and outputs the number of remaining players in order of smallest to largest number. However, each player is assigned a number from 1, and statements are made starting from the first player in order, and when all statements are finished, the first player will speak again. If the player whose turn it is has already dropped out, the next player will speak. Also, this program must ignore any statements made after a single player remains.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by two zeros.
Each dataset is given in the following format.
m n
s1
s2
:
sn
The first line gives the number of players m (2 ≤ m ≤ 1000) and the number of statements n (1 ≤ n ≤ 10000).
The following n lines give the i-th statement s1. si is an integer, Fizz, Buzz, or FizzBuzz, a string indicating them (up to 8 characters).
There are no more than 50 datasets in the input.
Output
For each dataset, output the numbers of the remaining players in order from smallest to largest after the specified number of statements has been input.
Sample Input
5 7
1
2
Fizz
4
Buzz
6
7
3 5
1
2
3
4
5
0 0
Output for the Sample Input
2 3 4 5
1

Extracted Specification

An integer m (2 ≤ m ≤ 1000), representing some quantity or size.
An integer n (1 ≤ n ≤ 10000), representing some quantity or size.
A list of n items, where each item is either an integer (1 ≤ item ≤ 10000) or a string from the set {'Fizz', 'Buzz', 'FizzBuzz'}.
There are no more than 50 such sets of inputs.

### Example Input:
```
5 7
1
2
Fizz
4
Buzz
6
7
3 5
1
2
3
4
5
0 0
```

### Function Signature:
Write a function f(inputs) that takes in the input.
```python
def f(inputs: List[Tuple[int, int, List[Union[int, str]]]]):
    '''
    inputs: a list of tuples, where each tuple contains:
        - an integer
        - an integer
        - a list of integers and strings
    '''
```

Test Case Generator

Certainly! Below is a Python function `tcgen` that generates test cases for the described "Fizz Buzz" problem statement:

```python
import random

def generate_statement(num):
    if num % 3 == 0 and num % 5 == 0:
        return "FizzBuzz"
    elif num % 3 == 0:
        return "Fizz"
    elif num % 5 == 0:
        return "Buzz"
    else:
        return str(num)

def tcgen():
    datasets = []
    for _ in range(random.randint(1, 50)):  # There are no more than 50 datasets in the input
        m = random.randint(2, 1000)  # Number of players (2 ≤ m ≤ 1000)
        n = random.randint(1, 10000)  # Number of statements (1 ≤ n ≤ 10000)
        
        statements = [generate_statement(i + 1) for i in range(n)]
        
        datasets.append((m, n, statements))
    
    return datasets

# Example usage
test_cases = tcgen()

# Printing generated test cases in the required format
for m, n, statements in test_cases:
    print(f"{m} {n}")
    for statement in statements:
        print(statement)
print("0 0")
```

### Explanation:
1. **generate_statement(num)**: This helper function takes a number and returns "Fizz", "Buzz", "FizzBuzz", or the number itself as a string depending on its divisibility by 3 and/or 5.
2. **tcgen()**: This function generates multiple datasets as specified:
    - It randomly chooses the number of datasets to generate (between 1 and 50).
    - For each dataset, it randomly determines the number of players (`m`) and the number of statements (`n`).
    - It then generates `n` statements using the `generate_statement` function.
    - All datasets are collected in a list and returned.
3. **Example usage**: The example usage part shows how to call the `tcgen` function to generate test cases and print them in the required format.

This generator ensures that we have a variety of test cases with different numbers of players and statements, covering the edge cases and providing thorough testing for the problem statement.

Extract Arguments

def extract_arguments(fh):
    datasets = []
    while True:
        m, n = map(int, fh.readline().strip().split())
        if m == 0 and n == 0:
            break
        statements = [fh.readline().strip() for _ in range(n)]
        datasets.append((m, n, statements))
    return datasets