A harborside tide-watch keeps its yearly predictions bound into a single almanac, one page per calendar day, numbered consecutively starting from page 1 on January 1st. When a keeper logs the date of an observation, the archive clerk needs to know which page of that year's almanac the observation belongs to, so the entry can be filed on the correct page — remembering that leap years get one extra page inserted for February 29th.
A single line containing a date in the exact format YYYY-MM-DD (a four-digit year, a two-digit month, and a two-digit day, separated by hyphens).
Print a single integer: the ordinal position of that date within its year (1 for January 1st, 32 for February 1st in a non-leap year, and so on) — the page number in the almanac.
1900 <= YYYY <= 210001 <= MM <= 12Example 1
Input
2019-01-09
Expected
9
Explanation
2019 is not a leap year. January 9th is simply the 9th day of the year, since it falls within the first month.
Example 2
Input
2019-02-10
Expected
41
Explanation
2019 is not a leap year, so January has 31 days. February 10th is therefore day 31 + 10 = 41 of the year.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →