Problem Statement
Tokyo Olympics 2021 is scheduled to start from the opening ceremony in July 23rd, 2021.
Suzuki, a man who lives in Japan, is looking forward to seeing the opening ceremony.
Now, he wants to calculate how many days are remaining to the opening ceremony.
(For example, if the opening ceremony were tomorrow, there would be 1 day remaining.)
Today's date is given as a string today in the format "YYYY.MM.DD". Day and month numbers have an extra leading zero if necessary. Some examples:
- If today's date is July 24th, 2020, today will be "2020.07.24".
- If today's date is November 9th, 2020, today will be "2020.11.09".
- If today's date is February 25th, 2021, today will be "2021.02.25".
For Suzuki, calculate and return how many days are remaining to the opening ceremony of Tokyo Olympics 2021.
Definition
- Class:
- NextOlympics
- Method:
- countDays
- Parameters:
- String
- Returns:
- int
- Method signature:
- int countDays(String today)
- (be sure your method is public)
Notes
- In this problem, you will implement the class "NextOlympics" with a public function named "countDays" which takes a string today as a parameter and returns an integer value.
- If you do not know about how to compete or how to write/compile/test/submit solutions, please refer to https://www.topcoder.com/community/competitive-programming/how-to-compete for detailed information about competing in SRM.
- And, don't forget testing at least on the example cases! In Applet Arena, you can test all example cases at once using "Batch Test". In Web Arena, you can test all example cases by checking all of them in the Test Panel.
- For testing on custom cases or attempting challenges in the Challenge Phase, the string you input should be enclosed in double quotes (""). For example, you can input "2020.07.24" including the quotes.
Constraints
- The string today will represent a valid date (in Gregorian Calendar) from July 24th 2020 to July 23rd 2021, inclusive.
Examples
"2020.07.24"
Returns: 364
TopCoder SRM 788 is taking place in July 24th, 2020. Here, Tokyo Olympics 2021 is less than one year from now! Given this, 364 days are remaining to the opening ceremony of the Olympics. By the way, July 24th, 2020 is a holiday in Japan called "Sports Day". It's a holiday to celebrate the Olympics.
"2020.11.09"
Returns: 256
In this example, "today" is November 9th, 2020. Here, 256 days are remaining until the Olympics begin. So, you should return 256 for this example. Suzuki has to wait 256 days for the opening ceremony.
"2021.02.25"
Returns: 148
In this example, "today" is February 25th, 2021. Here, 148 days are remaining until the opening ceremony. Suzuki has to wait 148 days for the opening ceremony.
"2021.07.23"
Returns: 0
In this example, "today" is July 23rd, 2021. It's the day of the opening ceremony of the Tokyo Olympics 2021. For this case, since there are 0 days remaining to the opening ceremony, you should return 0.
"2020.12.31"
Returns: 204
In this example, "today" is December 31st, 2020. There are 204 days remaining to the opening ceremony.
"2021.01.01"
Returns: 203
In this example, "today" is January 1st, 2021. There are 203 days remaining to the opening ceremony.
"2021.02.01"
Returns: 172
"2021.03.01"
Returns: 144
"2021.04.01"
Returns: 113
"2021.05.01"
Returns: 83
"2021.06.01"
Returns: 52
"2021.07.01"
Returns: 22
"2020.08.01"
Returns: 356
"2020.09.01"
Returns: 325
"2020.10.01"
Returns: 295
"2020.11.01"
Returns: 264
"2020.12.01"
Returns: 234
"2021.01.31"
Returns: 173
"2021.02.28"
Returns: 145
"2021.03.31"
Returns: 114
"2021.04.30"
Returns: 84
"2021.05.31"
Returns: 53
"2021.06.30"
Returns: 23
"2020.07.31"
Returns: 357
"2020.08.31"
Returns: 326
"2020.09.30"
Returns: 296
"2020.10.31"
Returns: 265
"2020.11.30"
Returns: 235
"2021.01.12"
Returns: 192
"2021.02.12"
Returns: 161
"2021.03.03"
Returns: 142
"2021.04.11"
Returns: 103
"2021.05.30"
Returns: 54
"2021.06.21"
Returns: 32
"2021.07.04"
Returns: 19
"2020.08.15"
Returns: 342
"2020.09.23"
Returns: 303
"2020.10.20"
Returns: 276
"2020.11.05"
Returns: 260
"2020.12.11"
Returns: 224
"2021.03.15"
Returns: 130