Analog Clock Display

Time limit1sMemory limit128 MB

Summary
Given times in HH:MM form, draw fixed-size ASCII analog clock faces with the hour and minute hands rasterized as line segments, following exact character rules.
Level

Medium7 of 10

Topics
Geometry, Simulation, Implementation, Math
Solved
No attempts yet

Problem

Our old clock chimed four o'clock, and with that final sound it crumbled into a pile of sticks. The craftsmanship needed to repair it was forgotten and lost long ago, so we decided to replace it with a computer program.

An easy task, you say? There is one more small thing to mention. Recent studies of extraterrestrial aliens have shown that they live in a digital world and are therefore unable to read a traditional clock face with two moving hands — it is simply beyond their technical capabilities. For this reason the Security Board has decided that our new clock must use exactly such a traditional "analog" display, so as to protect the time information from non-humans.

Input

The input contains several instances. Each instance is a single line holding two integers HH (0≤H≤230 \le H \le 23) and MM (0≤M≤590 \le M \le 59) separated by a colon. MM is always written with two digits; HH has one or two digits, i.e. it has no leading zero unless H=0H = 0.

The last instance is followed by a line containing the word END.

Output

For each input instance H:M, draw an ASCII-art clock face showing the time HH hours and MM minutes, following the specification below.

The face frame is a square with 5151 characters on each side. These characters are the uppercase letter X, except for the four corners and every tenth character, which are always @. The numbers 33, 66, 99, and 1212 are centered on their respective sides, with exactly one space between each number and the frame. Inside 1212 there is one space between the digits 11 and 22. The center of the face always holds an asterisk *. Every visually empty position is a plain space.

The two hands are the only parts of the face that depend on the time. In the description below, assume that each character cell (whether a space or not) is a 1×11 \times 1 square, and place the origin (0,0)(0, 0) of the coordinate system at the center of the cell holding the asterisk, with the first axis pointing right and the second axis pointing up.

The hour hand is a line segment of length 1515 starting at (0,0)(0, 0). It points straight up at 1212 o'clock and rotates uniformly by the same angle every minute. The minute hand is a line segment of length 2121 starting at (0,0)(0, 0); it points straight up every full hour and also rotates uniformly clockwise every minute. The minute hand is considered to lie above the hour hand, so characters of the hour hand may be hidden by parts of the minute hand.

A line whose angle from the vertical direction is DD degrees is drawn as follows. If 0≤D≤450 \le D \le 45, one character is printed for each row ii, at the integer coordinates (ni,i)(n_i, i) nearest to the point (xi,i)(x_i, i) that lies exactly on the geometric line (xix_i is a real number). If 45≤D≤9045 \le D \le 90, one character is printed for each column ii, at the integer coordinates (i,ki)(i, k_i) nearest to the real point (i,yi)(i, y_i) on the line.

The character drawn at a position (i,j)(i, j) depends on the two neighboring characters of the line. It is

  • a minus sign - if there are also characters at both (i−1,j)(i-1, j) and (i+1,j)(i+1, j),
  • a pipe | if there are also characters at both (i,j−1)(i, j-1) and (i,j+1)(i, j+1),
  • a backslash \ if there are characters at (i−1,j+1)(i-1, j+1) and (i+1,j−1)(i+1, j-1),
  • a slash / if there are also characters at (i−1,j−1)(i-1, j-1) and (i+1,j+1)(i+1, j+1),
  • a lowercase o otherwise.

A line segment of length SS starting at (0,0)(0, 0) is drawn by forming characters exactly as for the full line, but printing only those characters whose cell center lies within distance SS of the origin, i.e. 0<∣(0,0),(i,j)∣≤S0 < |(0,0),(i,j)| \le S, and only in the one direction of the line.

Refer to the sample outputs to resolve any remaining ambiguities. Separate consecutive clock faces with a single empty line.

Examples3

  1. Example 1

    Input
    1:03
    14:27
    END
    
    Expected output
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@
    X                                                 X
    X                       1 2                       X
    X                                                 X
    X                                                 X
    X                              o                  X
    X                              |                  X
    X                              |                  X
    X                              o                  X
    X                             o                   X
    @                             |                   @
    X                             o                   X
    X                            o                    X
    X                            |  o                 X
    X                            o  o                 X
    X                           o  o                  X
    X                           |  o                  X
    X                           o /                   X
    X                          o o                    X
    X                          | o                    X
    @                          o/                     @
    X                         oo                      X
    X                         |o                      X
    X                         o                       X
    X                        oo                       X
    X 9                      *                      3 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                        6                        X
    X                                                 X
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@
    
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@
    X                                                 X
    X                       1 2                       X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                    o--          X
    X                                 o-o             X
    X                              o-o                X
    X                          o--o                   X
    X 9                      *o                     3 X
    X                        o                        X
    X                         o                       X
    X                         |                       X
    X                         o                       X
    @                          o                      @
    X                          |                      X
    X                          o                      X
    X                           o                     X
    X                           |                     X
    X                           o                     X
    X                            o                    X
    X                            |                    X
    X                            o                    X
    X                             o                   X
    @                             |                   @
    X                             o                   X
    X                              o                  X
    X                              |                  X
    X                              |                  X
    X                              o                  X
    X                                                 X
    X                                                 X
    X                        6                        X
    X                                                 X
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@
    
  2. Example 2

    Input
    10:10
    END
    
    Expected output
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@
    X                                                 X
    X                       1 2                       X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                         oo      X
    X                                       oo        X
    X            oo                       oo          X
    X              \                     /            X
    X               oo                 oo             X
    @                 \              oo               @
    X                  oo           /                 X
    X                    \        oo                  X
    X                     \     oo                    X
    X                      oo oo                      X
    X 9                      *                      3 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                        6                        X
    X                                                 X
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@
    
  3. Example 3

    Input
    0:00
    END
    
    Expected output
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@
    X                                                 X
    X                       1 2                       X
    X                                                 X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    @                        |                        @
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    @                        |                        @
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X                        |                        X
    X 9                      *                      3 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    @                                                 @
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                                                 X
    X                        6                        X
    X                                                 X
    @XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@XXXXXXXXX@