Analog Clock Display
Time limit1sMemory limit128 MB
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 () and () separated by a colon. is always written with two digits; has one or two digits, i.e. it has no leading zero unless .
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 hours and minutes, following the specification below.
The face frame is a square with 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 , , , and are centered on their respective sides, with exactly one space between each number and the frame. Inside there is one space between the digits and . 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 square, and place the origin 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 starting at . It points straight up at o'clock and rotates uniformly by the same angle every minute. The minute hand is a line segment of length starting at ; 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 degrees is drawn as follows. If , one character is printed for each row , at the integer coordinates nearest to the point that lies exactly on the geometric line ( is a real number). If , one character is printed for each column , at the integer coordinates nearest to the real point on the line.
The character drawn at a position depends on the two neighboring characters of the line. It is
- a minus sign
-if there are also characters at both and , - a pipe
|if there are also characters at both and , - a backslash
\if there are characters at and , - a slash
/if there are also characters at and , - a lowercase
ootherwise.
A line segment of length starting at is drawn by forming characters exactly as for the full line, but printing only those characters whose cell center lies within distance of the origin, i.e. , 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.