#K8096. Days Between Dates in a 30-Day Month Calendar
Days Between Dates in a 30-Day Month Calendar
Days Between Dates in a 30-Day Month Calendar
You are given two dates in a unique calendar system where each month has exactly 30 days and there are 12 months per year. The dates are provided in the format Day-Month-Year
(for example, 15-january-1
).
Your task is to determine the absolute difference in days between the two dates.
In this calendar system, the conversion of a date d-month-y
to a total number of days is done as follows:
\( \text{TotalDays}(d, \text{month}, y) = d + \text{offset}(\text{month}) + (y - 1) \times 360 \)
where the month offsets are defined as:
- january: 0
- february: 30
- march: 60
- april: 90
- may: 120
- june: 150
- july: 180
- august: 210
- september: 240
- october: 270
- november: 300
- december: 330
The answer is the absolute difference between the total days of the two dates.
Input/Output: The input is read from standard input (stdin) and the output is printed to standard output (stdout).
inputFormat
The first line of input contains a single integer T
representing the number of test cases. Each of the next T
lines contains two dates separated by a space in the format Day-Month-Year
.
For example:
3 1-january-1 30-january-1 1-january-1 1-february-1 1-january-1 1-january-1
outputFormat
For each test case, output a single integer on a new line that represents the absolute number of days between the two given dates.
## sample3
1-january-1 30-january-1
1-january-1 1-february-1
1-january-1 1-january-1
29
30
0
</p>