TopcoderARCHIVE
Archive/Problems/TapeMeasure
SRM · Problem 16352

TapeMeasure

Problem statement, definition, constraints, and public examples.

Problem Statement

Here's the beginning of an ASCII art bitmap that depicts a tape measure:

###################################################
# # # # # # # # # # # # # # # # # # # # # # # # # #
#         #         #         #         #         #
#                   #                   #          
0                   10                  20         

A more formal description:

  • The first row is full of '#' marks and represents the top edge of the tape measure.
  • The second row shows unit marks in every second column.
  • Multiples of five get a longer mark that continues into the third row.
  • Multiples of ten get a mark that reaches all the way into the fourth row, and they also get labels in the fifth row. The label always begins in the column with the mark and extends to the right as needed.

You are given the ints leftMark and rightMark. Construct the drawing of the part of the tape measure that begins with the column containing the mark for number leftMark and ends with the column that contains the mark for the number rightMark. Return the drawing as a String[].

Definition

Class:
TapeMeasure
Method:
draw
Parameters:
int, int
Returns:
String[]
Method signature:
String[] draw(int leftMark, int rightMark)
(be sure your method is public)

Constraints

  • leftMark will be between 0 and 999, inclusive.
  • rightMark will be between leftMark and 999, inclusive.
  • rightMark - leftMark will be at most 25.

Examples

  1. 0
    25
    Returns: {"###################################################", "# # # # # # # # # # # # # # # # # # # # # # # # # #", "#         #         #         #         #         #", "#                   #                   #          ", "0                   10                  20         " }
    This is the exact example shown in the problem statement.
  2. 981
    990
    Returns: {"###################", "# # # # # # # # # #", "        #         #", "                  #", "0                 9" }
    Note how the labels for marks 980 and 990 are partially visible in this section of the tape measure. Below we show a section of the tape measure that is one mark wider on each side (left=980, right=991) so that you can see these labels completely. ####################### # # # # # # # # # # # # # # # # # 980 990
  3. 20
    20
    Returns: {"#", "#", "#", "#", "2" }
  4. 31
    38
    Returns: {"###############", "# # # # # # # #", "        #      ", "               ", "               " }
← All problems