Statistics

Problem Statement for "CalendarHTML"

Problem Statement

HTML is the markup language used on the World Wide Web. In HTML, the simplest type of table is formed as follows:

The table starts with "<table>" and ends with "</table>". These are the outermost tags, and within them are a number of rows. Each row starts with "<tr>" and ends with "</tr>". Within each row, there are a number of cells. Each cell starts with "<td>" and ends with "</td>". Between the "td" tags are the contents of the cell, which may be 0 or more characters. The rows are displayed in the same order they appear, and the cells within a row are also displayed in the same order they appear. For the purposes of this problem, every row will have the same number of cells. For example, the following HTML will render the table below:
<table>
<tr><td>A</td><td>B</td></tr>
<tr><td></td><td>C</td></tr>
</table>


Your task is to make a calendar for a particular month in HTML. The month has days days in it, and starts on day start, where 0 is Sunday, 1 is Monday, and so on. You should make a table for this month, with a single row for each week, and a single column for each day. In addition, you should have a header row, with 7 cells, containing the letters (in order) 'S', 'M', 'T', 'W', 'T', 'F', 'S'. You should then fill in the calendar with the days of the month, starting from the appropriate day of the first week (in the second row of the table) with a "1". Note that some of the cells at the beginning and end of the calendar may be empty, "<td></td>", but must still be included in the return. Be careful not to include any completely empty rows in your return though. For example, if days = 30 and start = 3, you would want to generate the following table:

You should return a String[], the first element of which is "<table>", and the last element of which is "</table>". Each element in between should represent a single row in the table, starting with "<tr>", and ending with "</tr>"

Definition

Class:
CalendarHTML
Method:
makeTable
Parameters:
int, int
Returns:
String[]
Method signature:
String[] makeTable(int days, int start)
(be sure your method is public)

Notes

  • All of the tags in the return should be lowercase, while the contents of the cells in the first row ('S', 'M', 'T', 'W', 'T', 'F', 'S') should be uppercase.
  • There should be no spaces or leading zeros anywhere in the return.

Constraints

  • days will be between 28 and 31, inclusive.
  • start will be between 0 and 6, inclusive.

Examples

  1. 30

    3

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234
    567891011
    12131415161718
    19202122232425
    2627282930
    " }

    The example from above.

  2. 28

    0

    Returns: { "

    ", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    " }

  3. 31

    6

    Returns: { "

    ", "", "", "", "", "", "", "", "
    SMTWTFS
    1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031
    " }

  4. 29

    0

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    29
    " }

  5. 30

    0

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    2930
    " }

  6. 28

    0

    Returns: { "

    ", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    " }

  7. 28

    1

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123456
    78910111213
    14151617181920
    21222324252627
    28
    " }

  8. 28

    2

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    12345
    6789101112
    13141516171819
    20212223242526
    2728
    " }

  9. 28

    3

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234
    567891011
    12131415161718
    19202122232425
    262728
    " }

  10. 28

    4

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123
    45678910
    11121314151617
    18192021222324
    25262728
    " }

  11. 28

    5

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    12
    3456789
    10111213141516
    17181920212223
    2425262728
    " }

  12. 28

    6

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1
    2345678
    9101112131415
    16171819202122
    232425262728
    " }

  13. 29

    0

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    29
    " }

  14. 29

    1

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123456
    78910111213
    14151617181920
    21222324252627
    2829
    " }

  15. 29

    2

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    12345
    6789101112
    13141516171819
    20212223242526
    272829
    " }

  16. 29

    3

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234
    567891011
    12131415161718
    19202122232425
    26272829
    " }

  17. 29

    4

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123
    45678910
    11121314151617
    18192021222324
    2526272829
    " }

  18. 29

    5

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    12
    3456789
    10111213141516
    17181920212223
    242526272829
    " }

  19. 29

    6

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1
    2345678
    9101112131415
    16171819202122
    23242526272829
    " }

  20. 30

    0

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    2930
    " }

  21. 30

    1

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123456
    78910111213
    14151617181920
    21222324252627
    282930
    " }

  22. 30

    2

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    12345
    6789101112
    13141516171819
    20212223242526
    27282930
    " }

  23. 30

    3

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234
    567891011
    12131415161718
    19202122232425
    2627282930
    " }

  24. 30

    4

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123
    45678910
    11121314151617
    18192021222324
    252627282930
    " }

  25. 30

    5

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    12
    3456789
    10111213141516
    17181920212223
    24252627282930
    " }

  26. 30

    6

    Returns: { "

    ", "", "", "", "", "", "", "", "
    SMTWTFS
    1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30
    " }

  27. 31

    0

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    293031
    " }

  28. 31

    1

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123456
    78910111213
    14151617181920
    21222324252627
    28293031
    " }

  29. 31

    2

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    12345
    6789101112
    13141516171819
    20212223242526
    2728293031
    " }

  30. 31

    3

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234
    567891011
    12131415161718
    19202122232425
    262728293031
    " }

  31. 31

    4

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    123
    45678910
    11121314151617
    18192021222324
    25262728293031
    " }

  32. 31

    5

    Returns: { "

    ", "", "", "", "", "", "", "", "
    SMTWTFS
    12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31
    " }

  33. 31

    6

    Returns: { "

    ", "", "", "", "", "", "", "", "
    SMTWTFS
    1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031
    " }

  34. 28

    0

    Returns: { "

    ", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    " }

  35. 31

    0

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234567
    891011121314
    15161718192021
    22232425262728
    293031
    " }

  36. 31

    6

    Returns: { "

    ", "", "", "", "", "", "", "", "
    SMTWTFS
    1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031
    " }

  37. 30

    3

    Returns: { "

    ", "", "", "", "", "", "", "
    SMTWTFS
    1234
    567891011
    12131415161718
    19202122232425
    2627282930
    " }


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: