Skip to content

Commit 68e4cab

Browse files
committed
Adding tests for "Folding a note".
1 parent 2daed22 commit 68e4cab

File tree

9 files changed

+128
-0
lines changed

9 files changed

+128
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- Tests for "Frog exchange".
3636
- Tests for "Fair numbering".
3737
- Tests for "A coin guessing game".
38+
- Tests for "Folding a note".
3839

3940
## [1.11.0] - 2022-07-31
4041
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Folding a note" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/folding-a-note}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
const L = readline();
9+
}
10+
11+
// Write an answer using console.log()
12+
// To debug: console.error('Debug messages...');
13+
14+
console.log('decoded note');
15+
16+
}
17+
18+
export { execute };
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { assertOutputAnswer } from '../../../../assertOutputAnswer.js';
5+
import { execute } from '../../../../../lib/community/training/medium/foldingANote/foldingANote.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Folding a note", function() {
10+
const sandbox = sinon.createSandbox();
11+
12+
setup(function () {
13+
sandbox.stub(console, "log");
14+
});
15+
16+
teardown(function () {
17+
sandbox.restore();
18+
});
19+
20+
21+
test("Easy", function() {
22+
let inputFile = new File(__dirname + 'input/01 - easy.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
"A"
29+
);
30+
});
31+
32+
test("LOL", function() {
33+
let inputFile = new File(__dirname + 'input/02 - LOL.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
"LMAO"
40+
);
41+
});
42+
43+
test("Brooo...", function() {
44+
let inputFile = new File(__dirname + 'input/03 - brooo....txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
"Duuuuuuuuuuuude!"
51+
);
52+
});
53+
54+
test("Piggy", function() {
55+
let inputFile = new File(__dirname + 'input/04 - piggy.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
"The supervisor looks like a hog! Oink oink... I want some bacon."
62+
);
63+
});
64+
65+
test("I really like detention.", function() {
66+
let inputFile = new File(__dirname + 'input/05 - i really like detention.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assertOutputAnswer(__dirname + 'output/05 - i really like detention.txt');
71+
});
72+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
A
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
OA
3+
LM
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
uDuu
3+
u!eu
4+
uudu
5+
uuuu
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
krloo vi
3+
nmw Iaok
4+
ie. On o
5+
eeT!ghp
6+
s hoeua
7+
kacniob
8+
. t. ns.
9+
soskril
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
16
2+
onssoe rnynmw
3+
i c i f eodnsres
4+
lis .eann ,a ke
5+
sfwienw irt uae
6+
I rhaAp w eoet
7+
lomr. ahsyta t
8+
xb shifrmocwpsle
9+
foo ekognsi eui
10+
ps,eh erisltslss
11+
fswt, so h oai
12+
elaI pu cop. hsh
13+
ckne oeihnwhldah
14+
j m syoytehylhn
15+
f aon m diIelmee
16+
etahtt ncre ieht
17+
gfreti nimt eeos
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy.

0 commit comments

Comments
 (0)