Write a function that, given a valid date made with a day @d@, a
month @m@ and a year @y@, returns its day of the week, that is,
“Monday”, or “Tuesday”, or …
To compute it, use the congruence of Zeller. Let be the day, be the month, and be the year. Then,
Subtract two from the month , and if the result is zero or less, add 12 to the month and subtract one from the year. Call the new month and call the new year.
Compute the century (the first two digits of the year) from the year .
Compute the year inside the century (the two last digits of the year) from the year .
Compute
Finally, modulo 7 gives us the desired result, taking into account that 0 represents Sunday, 1 represents Monday, 2 represents Tuesday, …, and 6 represents Saturday.
| C++ | |
| C++ | |
| Java | |
| Python | |
|
|
| Haskell | |
The parameter @y@ is between 1800 and 9999, both included. The date is valid.
Watch out for modulos of negative numbers!
You only need to submit the required procedure; your main program will be ignored.
Input/Output