Skip to content

Commit bac4ee2

Browse files
rodolfoprrReenaRajani
authored andcommitted
Add Berlin Clock Kata (#46)
1 parent 125e022 commit bac4ee2

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

katas/berlin-clock-kata/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Berlin Clock Kata
2+
3+
## Problem Description
4+
5+
The "Berlin Clock" is the first public clock in the world that tells the time by means of illuminated, coloured fields, for which it entered the Guinness Book of Records upon its installation on 17 June 1975.
6+
7+
<img src="https://upload.wikimedia.org/wikipedia/commons/4/4f/Berlin-Uhr-1650-1705.gif" />
8+
9+
The clock is read from the top row to the bottom. The top row of four red fields denote five full hours each, alongside the second row, also of four red fields, which denote one full hour each, displaying the hour value in 24-hour format. The third row consists of eleven yellow-and-red fields, which denote five full minutes each (the red ones also denoting 15, 30 and 45 minutes past), and the bottom row has another four yellow fields, which mark one full minute each. The round yellow light on top blinks to denote even- (when lit) or odd-numbered (when unlit) seconds.
10+
11+
Example: Two fields are lit in the first row (five hours multiplied by two, i.e. ten hours), but no fields are lit in the second row; therefore the hour value is 10.
12+
Six fields are lit in the third row (five minutes multiplied by six, i.e. thirty minutes), while the bottom row has one field on (plus one minute). Hence, the lights of the clock altogether tell the time as 10:31.
13+
14+
#### Requirements
15+
16+
Task: Write a function that takes in a particular time as 24h format ('hh:mm:ss') and outputs a string that reproduces the Berlin Clock. The parameters should be as follows:
17+
18+
```
19+
“O” = Light off
20+
“R” = Red light
21+
“Y” = Yellow light
22+
23+
Example Test Case:
24+
Input String:
25+
12:56:01
26+
27+
Output String:
28+
O
29+
RROO
30+
RROO
31+
YYRYYRYYRYY
32+
YOOO
33+
```
34+
35+
If you are feeling adventurous, you can have the output as an HTML page (maybe using Angular, React, Vue.js...).
36+
37+
From: https://www.codewars.com/kata/berlin-clock

0 commit comments

Comments
 (0)