Statistics

Problem Statement for "FridayTheThirteenth"

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

  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.

  2. 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.

  3. 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.

  4. 1

    0

    Returns: {0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 }

  5. 2

    0

    Returns: {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1 }

  6. 3

    0

    Returns: {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }

  7. 4

    0

    Returns: {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 }

  8. 5

    0

    Returns: {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }

  9. 0

    1

    Returns: {1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 }

  10. 2

    1

    Returns: {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }

  11. 3

    1

    Returns: {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 }

  12. 4

    1

    Returns: {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }

  13. 5

    1

    Returns: {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }

  14. 6

    1

    Returns: {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: