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 int[] with 12 elements. For each i between 0 and 11, inclusive, element i of the return value should be the number of times Friday the 13th will appear in month (i+1) of the given year.
Definition
- Class:
- FridayTheThirteenth
- Method:
- count
- Parameters:
- int, int
- Returns:
- int[]
- Method signature:
- int[] count(int firstDay, int isLeap)
- (be sure your method is public)
Constraints
- firstDay will be between 0 and 6, inclusive.
- isLeap will be either 0 or 1.
Examples
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.