Orig Description
Hit and Blow
Let's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:
The number of numbers which have the same place with numbers A imagined (Hit)
The number of numbers included (but different place) in the numbers A imagined (Blow)
For example, if A imagined numbers:
9 1 8 2
and B chose:
4 1 5 9
A should say 1 Hit and 1 Blow.
Write a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.
Input
The input consists of multiple datasets. Each dataset set consists of:
a1 a2 a3 a4
b1 b2 b3 b4
, where ai (0 ≤ ai ≤ 9) is i-th number A imagined and bi (0 ≤ bi ≤ 9) is i-th number B chose.
The input ends with EOF. The number of datasets is less than or equal to 50.
Output
For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.
Sample Input
9 1 8 2
4 1 5 9
4 6 8 2
4 6 3 2
Output for the Sample Input
1 1
3 0
Extracted Specification
An integer ai (0 ≤ ai ≤ 9), representing the i-th element in the first sequence.
An integer bi (0 ≤ bi ≤ 9), representing the i-th element in the second sequence.
The input consists of multiple datasets. Each dataset consists of:
Four integers ai (0 ≤ ai ≤ 9).
Four integers bi (0 ≤ bi ≤ 9).
The input ends with EOF. The number of datasets is less than or equal to 50.
### Example Input:
```
9 1 8 2
4 1 5 9
4 6 8 2
4 6 3 2
```
### Function Signature:
Write a function f(inputs) that takes in the input.
```python
def f(inputs: List[Tuple[List[int], List[int]]]):
'''
inputs: a list of tuples, each containing two lists of four integers each
'''
```
Test Case Generator
Sure, let's write a test case generator for the "Hit and Blow" problem. The generator will create multiple datasets of inputs where each dataset consists of two sets of four unique numbers between 0 and 9.
Here's the test case generator:
```python
import random
def generate_unique_numbers():
return random.sample(range(10), 4)
def tcgen():
num_datasets = random.randint(1, 50)
test_cases = []
for _ in range(num_datasets):
A = generate_unique_numbers()
B = generate_unique_numbers()
test_cases.append((A, B))
return test_cases
# Example usage
test_cases = tcgen()
for A, B in test_cases:
print(" ".join(map(str, A)))
print(" ".join(map(str, B)))
```
### Explanation:
1. **generate_unique_numbers function**: This utility function uses `random.sample` to generate a list of 4 unique numbers between 0 and 9.
2. **tcgen function**:
- It first randomly determines the number of datasets (from 1 to 50).
- For each dataset, it generates two sets of 4 unique numbers using the `generate_unique_numbers` function.
- The datasets are stored in the `test_cases` list.
- Finally, it returns the list of test cases.
### Example Usage Output:
When you run the generator, it will print the datasets in the required format:
```
9 1 8 2
4 1 5 9
4 6 8 2
4 6 3 2
...
```
Each pair of lines represents one dataset, with the first line being the numbers A imagined and the second line being the numbers B chose. You can run the generator multiple times to get different sets of test cases.
Extract Arguments
def extract_arguments(fh):
inputs = []
while True:
line = fh.readline().strip()
if not line:
break
A = list(map(int, line.split()))
B = list(map(int, fh.readline().strip().split()))
inputs.append((A, B))
return inputs
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# inputs = extract_arguments(fh)
# f(inputs)