A common year is a year that is not a leap year and where the first and last day of the year are on the same day. A special common year is one that starts on a Monday and so ends on a Monday as well.
Your challenge is to create a program/function that when given a year as input finds the nearest special common year, outputting itself if it is a common year. If the year is as close to the one before it as the one next to it output the larger one.
Input
An integer representing the year to test against in the range 1600 <= x <= 2100
.
Output
An integer representing the nearest special common year.
Test cases
2017 -> 2018
2018 -> 2018
1992 -> 1990
1600 -> 1601
2100 -> 2103
1728 -> 1731 (lies between 1725 and 1731)
Notes
All 54 years in the given range are already shown in the linked Wikipedia article. I will also provide them here for reference:
1601, 1607, 1618, 1629, 1635, 1646, 1657, 1663, 1674, 1685, 1691
1703, 1714, 1725, 1731, 1742, 1753, 1759, 1770, 1781, 1787, 1798
1810, 1821, 1827, 1838, 1849, 1855, 1866, 1877, 1883, 1894, 1900
1906, 1917, 1923, 1934, 1945, 1951, 1962, 1973, 1979, 1990
2001, 2007, 2018, 2029, 2035, 2046, 2057, 2063, 2074, 2085, 2091
2103 (Needed for 2097 to 2100)
6, 11, 11
. IE 6 years after the first is another, 11 years after that is another, 11 years after that is another, 6 years after that is another, etc. \$\endgroup\$a year that is not a leap year and where the first and last day of the year are on the same day
The second part of that definition is redundant. All non-leap years start and end on the same day, being exactly 52 weeks and one day (365 days) long. \$\endgroup\$