11
0
How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less?
You job is to write a program to count how many months, in a month range, are having a full 31 days and how many are having less than 31 days by "counting the knuckles".
Courtesy: amsi.org.au
Input
A pair of months, the first of which doesn't have to come chronologically before the second, given in any suitable format. For instance: 201703 201902
— March 2017 to February 2019. Please describe the input format you choose. Note that the input must be able to include all years from 1 to 9999. The range of months specified includes both the starting and ending months.
Output
Two integers: the number of months in the given range with 31 days and the number of months in the range with less than 31 days.
Example: 14 10
— 14 knuckles, 10 grooves (it means that in that month range we have 14 months that have a full 31 days, and 10 months that have less than 31 days).
For an input where the second month in the range comes chronologically before the first, for example 201612 201611
, you have to output a pair of zero.
Examples of input and output
| Input | Output |
|---------------|-------------|
| 201703 201902 | 14 10 |
| 201701 202008 | 26 18 |
| 000101 999912 | 69993 49995 |
| 201802 201803 | 1 1 |
| 201601 201601 | 1 0 |
| 201612 201611 | 0 0 |
Rules
- You may choose any language you like
- One input per line
- This is code-golf, so shortest code in bytes wins!
- The winner will be chosen in April 9
- Standard loopholes apply
- PS: this is my first question in PCG, it might have some inconsistencies. Feel free to edit and confirm what's unclear for you.
5You say the first of which is guaranteed to come chronologically before the second, but this is false for test case
201612 201611
. – Dennis – 2017-03-30T07:23:11.2732
There exists a sandbox on the site where you can post the question solely to get all the doubts cleared.
– ghosts_in_the_code – 2017-03-30T08:05:39.9831Thirty days hath September, April, June, and November. After February's done, all the rest have thirty-one. That's how I remember it. – AdmBorkBork – 2017-03-30T12:33:50.500
@AdmBorkBork The only trouble with that is the infinite looping (mandatory xkcd reference).
– wizzwizz4 – 2017-03-30T18:19:57.163I presume you intend to use the Gregorian calendar throughout the date range? – Paused until further notice. – 2017-03-30T19:57:58.047
@Dennis and all, Just came back online today. I'm going to clarify that the last test case is valid. Actually I wrote a rule for that, before it got edited. Check back my edited question again. Thanks!
– Rizki Pratama – 2017-03-31T02:16:53.633@softtama That's unfortunate, as it invalidates at least four answers, including my own. While I realize now that the conflict was caused by someone else's edit, it's usually preferable to chose the option that doesn't invalidate answers, unless doing so actively hurts the challenge. – Dennis – 2017-03-31T15:34:56.147