FridayTheThirteenth
SRM 832 · 2022-06-24 · by misof
Problem Statement
Let's number the days of the week as follows: Sunday=0, Monday=1, Tuesday=2, Wednesday=3, Thursday=4, Friday=5 and Saturday=6.
You are given two numbers:
- firstDay: a value from {0,1,2,3,4,5,6} telling you which day of the week is January 1st.
- isLeap: a value from {0,1} that is 1 if the year is a leap year and 0 if it's not.
In an ordinary year the months have the following numbers of days: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31. In a leap year February has 29 days instead of 28.
Return a
Constraints
- firstDay will be between 0 and 6, inclusive.
- isLeap will be either 0 or 1.
6
0
Returns: {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }
This test case describes the current year: it started on a Saturday and it's not a leap year. In such a year there is only one Friday the 13th: in May.
0
0
Returns: {1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }
Year 2023 is one of the years that match this input. There will be two Fridays the 13th: one in January and the other in October.
1
1
Returns: {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1 }
One of the years that match this input is the year 2024. Its Fridays the 13th fall on September and December.
1
0
Returns: {0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 }
2
0
Returns: {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1 }
Submissions are judged against all 14 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FridayTheThirteenth with a public method vector<int> count(int firstDay, int isLeap) · 14 test cases · 2 s / 256 MB per case