Orig Description
League Standings Score Sheet
There are league and tournament games in sports. In soccer leagues, points are awarded for wins, losses, and draws, and rankings are determined by those points. The points awarded for each are as follows: win (3 points), loss (0 points), and draw (1 point).
Create a program that inputs the number of teams and their league record, sorts them in order of good performance (based on the number of points) and outputs the team name and points. In case of a tie in points, output in the order of input.
Input
Multiple data sets will be given. Each data set will be in the following format:
n
name1 w1 l1 d1
name2 w2 l2 d2
:
namen wn ln dn
The number of teams, n (n ≤ 10), is given on the first line. On the following n lines, the name namei of team i (up to 20 alphabets), the number of wins wi, the number of losses li, and the number of draws di (0 ≤ wi, li, di ≤ 9) are given, separated by spaces.
When the number of teams is 0, the input is terminated. The number of data sets will not exceed 50.
Output
For each data set, output a list of the sorted teams. On the i-th line, output the name and points of the i-th team separated by a comma.
Insert one blank line between data sets.
Sample Input
4
Japan 1 0 2
Egypt 1 2 0
Canada 0 2 1
Spain 2 0 1
3
India 0 2 0
Poland 1 0 1
Italy 1 0 1
0
Output for the Sample Input
Spain,7
Japan,5
Egypt,3
Canada,1
Poland,4
Italy,4
India,0
Extracted Specification
An integer \( n \) (1 ≤ \( n \) ≤ 10), representing some quantity or size. The number of data sets will not exceed 50.
Multiple lines follow, with each line containing:
- A string (up to 20 alphabets) representing a name.
- Three integers \( w \), \( l \), \( d \) (0 ≤ \( w, l, d \) ≤ 9), representing some quantities.
The input ends when \( n = 0 \).
### Example Input:
```
4
TeamA 1 0 2
TeamB 1 2 0
TeamC 0 2 1
TeamD 2 0 1
3
TeamE 0 2 0
TeamF 1 0 1
TeamG 1 0 1
0
```
### Function Signature:
Write a function `f(inputs)` that takes in the input.
```python
def f(inputs: List[Tuple[int, List[Tuple[str, int, int, int]]]]):
'''
inputs: a list of tuples, where each tuple consists of:
- an integer
- a list of tuples, each containing a string and three integers
'''
```
Test Case Generator
Certainly! Below is a Python function that generates test cases for the "League Standings Score Sheet" problem statement:
```python
import random
import string
def random_team_name():
length = random.randint(1, 20)
return ''.join(random.choices(string.ascii_letters, k=length))
def tcgen():
datasets = []
# Generate a random number of datasets (up to 50)
num_datasets = random.randint(1, 50)
for _ in range(num_datasets):
# Number of teams (n) for this dataset
n = random.randint(1, 10)
# Generate information for each team
teams = []
for _ in range(n):
name = random_team_name()
w = random.randint(0, 9)
l = random.randint(0, 9)
d = random.randint(0, 9)
teams.append(f"{name} {w} {l} {d}")
# Append dataset to the datasets list
datasets.append(f"{n}\n" + "\n".join(teams))
# Append the terminating 0 to indicate the end of input
datasets.append("0")
return "\n\n".join(datasets)
# Example usage:
print(tcgen())
```
### Explanation:
1. **Function `random_team_name`**: Generates a random team name with a length between 1 and 20 characters. The name consists of random uppercase and lowercase letters.
2. **Function `tcgen`**:
- Generates a random number of datasets (up to 50).
- For each dataset:
- Generates a random number of teams (n) between 1 and 10.
- For each team, it generates a random name and random values for wins (w), losses (l), and draws (d) between 0 and 9.
- Constructs a string representation of the dataset.
- Appends all datasets to the `datasets` list.
- Adds the terminating "0" to indicate the end of input.
- Joins all datasets with double newlines separating them and returns the final string.
This generator ensures that the test cases are varied and cover different scenarios, making it useful for testing the robustness of your solution to the problem.
Extract Arguments
def extract_arguments(fh):
data_sets = []
while True:
n = int(fh.readline().strip())
if n == 0:
break
teams = []
for _ in range(n):
line = fh.readline().strip().split()
name = line[0]
w, l, d = map(int, line[1:])
teams.append((name, w, l, d))
data_sets.append((n, teams))
return data_sets
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# data_sets = extract_arguments(fh)
# for data_set in data_sets:
# f(data_set)