Skip to content

Commit 51e61c8

Browse files
Ticiana de AndradeTiciana de Andrade
Ticiana de Andrade
authored and
Ticiana de Andrade
committed
Rename folders and add latest Kata
1 parent 2115bd6 commit 51e61c8

File tree

17 files changed

+520
-1
lines changed

17 files changed

+520
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
2-
.vscode/
2+
.vscode/
3+
.DS_Store
File renamed without changes.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
const assert = require('assert');
2+
3+
function secondStatus(seconds){
4+
if (seconds % 2 == 1)
5+
return "O";
6+
else
7+
return "Y";
8+
}
9+
10+
function fiveHoursStatus(hours){
11+
const a = Math.floor(hours / 5);
12+
switch (a) {
13+
case 1:
14+
return 'ROOO';
15+
break;
16+
case 2:
17+
return 'RROO';
18+
break;
19+
case 3:
20+
return 'RRRO';
21+
break;
22+
case 4:
23+
return 'RRRR';
24+
break;
25+
default:
26+
return 'OOOO';
27+
break;
28+
}
29+
}
30+
31+
function oneHourStatus(hours){
32+
const a = hours % 5;
33+
switch(a){
34+
case 1:
35+
return "ROOO";
36+
break;
37+
case 2:
38+
return "RROO";
39+
break;
40+
case 3:
41+
return "RRRO";
42+
break;
43+
case 4:
44+
return "RRRR";
45+
break;
46+
default:
47+
return "OOOO";
48+
break;
49+
}
50+
51+
}
52+
53+
function fiveMinutesStatus(minutes){
54+
let yellowLightOn = 'Y';
55+
let lightsOff = 'O';
56+
let redLightOn = 'YYR';
57+
let currentMins = minutes / 5;
58+
59+
if (minutes % 3 === 0)
60+
{
61+
let quotient = minutes / 15;
62+
const numRedLightsOn = redLightOn.repeat(quotient);
63+
const reminderLights = lightsOff.repeat(11 - 3);
64+
return numRedLightsOn + reminderLights
65+
}
66+
67+
68+
const lightsOn = yellowLightOn.repeat(currentMins);
69+
const remainingLights = lightsOff.repeat(11 - currentMins);
70+
return lightsOn + remainingLights;
71+
}
72+
73+
describe("Berlin Clock", () => {
74+
75+
it("Given a 1 second, returns OFF", () => {
76+
assert.equal(secondStatus(1), "O")
77+
});
78+
79+
it("Given a 2 second, returns ON", () => {
80+
assert.equal(secondStatus(2), "Y")
81+
});
82+
83+
it("Given 0 seconds, returns ON", () => {
84+
assert.equal(secondStatus(0), "Y")
85+
});
86+
87+
it("Given 1 hour, returns OOOO", () => {
88+
assert.equal(fiveHoursStatus(1), "OOOO")
89+
});
90+
it("Given 5 hour, returns ROOO", () => {
91+
assert.equal(fiveHoursStatus(5), "ROOO")
92+
});
93+
it("Given 10 hour, returns RROO", () => {
94+
assert.equal(fiveHoursStatus(10), "RROO")
95+
});
96+
it("Given 12 hour, returns RROO", () => {
97+
assert.equal(fiveHoursStatus(12), "RROO")
98+
});
99+
it("Given 15 hour, returns RRRO", () => {
100+
assert.equal(fiveHoursStatus(15), "RRRO")
101+
});
102+
it("Given 20 hour, returns RRRR", () => {
103+
assert.equal(fiveHoursStatus(20), "RRRR")
104+
});
105+
106+
it("Given 1 hour, returns ROOO", () => {
107+
assert.equal(oneHourStatus(1), "ROOO")
108+
});
109+
110+
it("Given 2 hour, returns RROO", () => {
111+
assert.equal(oneHourStatus(2),"RROO")
112+
});
113+
114+
it("Given 3 hour, returns RRRO", () =>{
115+
assert.equal(oneHourStatus(3), "RRRO")
116+
});
117+
118+
it("Given 4 hour, returns RRRR", () =>{
119+
assert.equal(oneHourStatus(4), "RRRR")
120+
});
121+
122+
it("Given 5 hour, returns OOOO", () =>{
123+
assert.equal(oneHourStatus(5), "OOOO")
124+
});
125+
126+
it("Given 6 hour, returns ROOO", () => {
127+
assert.equal(oneHourStatus(6), "ROOO")
128+
});
129+
130+
it("Given 0 minutes, returns OOOOOOOOOOO", () => {
131+
assert.equal(fiveMinutesStatus(0), "OOOOOOOOOOO")
132+
});
133+
134+
it("Given 5 minutes, returns YOOOOOOOOOO", () => {
135+
assert.equal(fiveMinutesStatus(5), "YOOOOOOOOOO")
136+
});
137+
138+
it("Given 10 minutes, returns YYOOOOOOOOO", () => {
139+
assert.equal(fiveMinutesStatus(10), "YYOOOOOOOOO")
140+
});
141+
142+
it("Given 15 minutes, returns YYROOOOOOOO", () => {
143+
assert.equal(fiveMinutesStatus(15), "YYROOOOOOOO")
144+
});
145+
});

2018/10-05-2018/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* **Format:** Mob Programming
2+
* **Katas:** Berlin Clock and Fizz Buzz Kata
3+
* **Where:** Arbor Networks
4+
* **When:** 10/05/2018
5+
6+
<img src="https://secure.meetupstatic.com/photos/event/9/c/f/d/highres_470980189.jpeg" width="600px" />
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

2018/10-05-2018/berlin-clock-kata/package-lock.json

Lines changed: 171 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "berlin-clock-kata",
3+
"version": "1.0.0",
4+
"description": "## Problem Description",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha -w"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
"mocha": "^5.0.5"
13+
}
14+
}

0 commit comments

Comments
 (0)