Orig Description
Number of Days
Write a program that takes two dates as input and outputs the number of days between those two dates. Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2), and date 1 is included in the count, but date 2 is not. Please calculate taking leap years into consideration. The conditions for leap years are as follows:
The year is divisible by 4.
However, years divisible by 100 are not leap years.
Years divisible by 400 are leap years.
Input
Multiple datasets will be given. The format for each dataset is as follows:
y1 m1 d1 y2 m2 d2
If any of y1, m1, d1, y2, m2, or d2 is a negative number, the input will end.
The number of datasets will not exceed 50.
Output
For each dataset, output the number of days on one line.
Sample Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output for the Sample Input
1
70
366
2192
36890
Extracted Specification
An integer y1 (0 ≤ y1 ≤ 10000), representing some quantity or size.
An integer m1 (1 ≤ m1 ≤ 12), representing some quantity or size.
An integer d1 (1 ≤ d1 ≤ 31), representing some quantity or size.
An integer y2 (0 ≤ y2 ≤ 10000), representing some quantity or size.
An integer m2 (1 ≤ m2 ≤ 12), representing some quantity or size.
An integer d2 (1 ≤ d2 ≤ 31), representing some quantity or size.
Multiple datasets will be given. If any of y1, m1, d1, y2, m2, or d2 is a negative number, the input will end. The number of datasets will not exceed 50.
### Example Input:
```
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
```
### Function Signature:
Write a function f(inputs) that takes in the input.
```python
def f(inputs: List[Tuple[int, int, int, int, int, int]]):
'''
inputs: a list of tuples, where each tuple contains six integers
'''
```
Test Case Generator
Certainly! Below is a test case generator for the "Number of Days" problem. The generator will randomly create valid date pairs within a range and will also include the termination condition with negative numbers.
```python
import random
from datetime import datetime, timedelta
def random_date(start_year=1900, end_year=2100):
year = random.randint(start_year, end_year)
month = random.randint(1, 12)
# Ensure the day is valid for the month
day = random.randint(1, 28)
if month in [1, 3, 5, 7, 8, 10, 12]:
day = random.randint(1, 31)
elif month in [4, 6, 9, 11]:
day = random.randint(1, 30)
elif month == 2:
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
day = random.randint(1, 29)
else:
day = random.randint(1, 28)
return year, month, day
def tcgen():
datasets = []
for _ in range(random.randint(1, 50)):
y1, m1, d1 = random_date()
y2, m2, d2 = random_date(y1, y1 + 100) # Ensure y2 is greater than or equal to y1
# Ensure date2 is after or same as date1
date1 = datetime(y1, m1, d1)
date2 = datetime(y2, m2, d2)
if date2 < date1:
date1, date2 = date2, date1
y1, m1, d1 = date1.year, date1.month, date1.day
y2, m2, d2 = date2.year, date2.month, date2.day
datasets.append((y1, m1, d1, y2, m2, d2))
# Include the termination condition
datasets.append((-1, -1, -1, -1, -1, -1))
return datasets
# Example usage of the test case generator
test_cases = tcgen()
for case in test_cases:
print(case)
```
This test case generator creates multiple datasets with valid date pairs, ensuring that the second date is always the same or after the first date. It also includes a termination condition with negative numbers as specified. Each dataset is a tuple `(y1, m1, d1, y2, m2, d2)`, making it easy to use as input for the problem.
Extract Arguments
def extract_arguments(fh):
inputs = []
while True:
line = fh.readline().strip()
if not line:
break
y1, m1, d1, y2, m2, d2 = map(int, line.split())
if min(y1, m1, d1, y2, m2, d2) < 0:
break
inputs.append((y1, m1, d1, y2, m2, d2))
return inputs