Who doesn't like to chill on a Sunday morning in summer with a chilled beer and TV or in winter playing badminton or ultimate with friends?
I always think knowing how many days you have to chill in a month keeps you well-informed and helps you plan what you want to do. Be it sitting in front of your pc and solving a code-golf problem or going out to play football.
So, help me write a program or function which takes as input 2 positive integers, Y
and M
and outputs the number of Sundays in that particular year(Y
) and month(M
) (according to the Gregorian Calendar), followed by the date of each Sunday.
Also, do keep in mind that the shortest code wins.
Input Constraints
1000 <= Y <= 9999
1 <= M <= 12
Output
These test cases will have output will have the dates of each Sunday of that month in that year in the format DD-MM-YYYY
.
Sample Test Cases
Test Case 1
Sample Input
2017 1
Sample Output
5
01-01-2017
08-01-2017
15-01-2017
22-01-2017
29-01-2017
Test Case 2
Sample Input
2018 2
Sample Output
4
04-02-2018
11-02-2018
18-02-2018
25-02-2018
Test Case 3
Sample Input
2016 11
Sample Output
4
06-11-2016
13-11-2016
20-11-2016
27-11-2016
Date()
object, and any output format, including[4, [<dateobj>, <dateobj>, <dateobj>, <dateobj>]]
(where<dateobj>
is an actual date object, and[]
is an actual array). \$\endgroup\$/
instead of-
? Or can it be month, then day, then year? \$\endgroup\$