Orig Description
A + B Problem
Compute A + B.
Input
The input will consist of a series of pairs of integers A and B separated by a space, one pair of integers per line. The input will be terminated by EOF.
Output
For each pair of input integers A and B, you must output the sum of A and B in one line.
Constraints
-1000 ≤ A, B ≤ 1000
Sample Input
1 2
10 5
100 20
Output for the Sample Input
3
15
120
Sample Program
#include
int main(){
int a, b;
while( scanf("%d %d", &a, &b) != EOF ){
printf("%d\n", a + b);
}
return 0;
}
Extracted Specification
Canonicalized Input Description:
An unspecified number of lines, each containing a pair of integers separated by a space. Each integer is between -1000 and 1000.
### Example Input:
```
1 2
10 5
100 20
```
### Function Signature:
Write a function f(inputs) that takes in the input as a list of tuples.
def f(inputs: List[Tuple[int, int]]):
'''
inputs: a list of tuples, where each tuple contains two integers
'''
Test Case Generator
To generate test cases for the "A + B Problem," we need to create pairs of integers within the specified range and format the output accordingly. The input consists of multiple lines until EOF, hence the test case generator will produce a variable number of lines each containing a pair of integers between -1000 and 1000.
Here's the test case generator for the "A + B Problem":
```python
import random
def tcgen(num_cases=10):
# Generate a random number of cases if not specified (between 1 and 100 for variety)
if num_cases is None:
num_cases = random.randint(1, 100)
test_cases = []
for _ in range(num_cases):
A = random.randint(-1000, 1000)
B = random.randint(-1000, 1000)
test_cases.append((A, B))
return test_cases
# Example of how to use the generator and print the test cases
if __name__ == "__main__":
test_cases = tcgen()
for a, b in test_cases:
print(f"{a} {b}")
```
### Explanation:
1. **Import `random` module**: Used to generate random integers.
2. **Function `tcgen(num_cases=10)`**:
- **Parameter `num_cases`**: Optional parameter to specify how many test cases to generate. Defaults to 10 if not specified.
- **If `num_cases` is `None`**: Randomly selects a number of cases between 1 and 100 to add variety.
- **Generate pairs**: For each test case, it generates two integers `A` and `B` within the range [-1000, 1000] and appends the pair `(A, B)` to the list `test_cases`.
3. **Return `test_cases`**: The function returns the list of generated test cases.
4. **Example usage**: The script prints each test case in the required format.
This generator can easily be adapted to produce different numbers of test cases by changing the `num_cases` parameter. It ensures that the generated pairs are within the given constraints and formats them correctly for the problem statement.
Extract Arguments
def extract_arguments(fh):
inputs = []
for line in fh:
A, B = map(int, line.strip().split())
inputs.append((A, B))
return inputs
# if __name__ == "__main__":
# import sys
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# inputs = extract_arguments(fh)
# f(inputs)