Skip to content

Commit 9716805

Browse files
committed
Adding tests for "Blunder - episode 2".
1 parent 86c842c commit 9716805

File tree

12 files changed

+16881
-0
lines changed

12 files changed

+16881
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
### Added
9+
- Tests for "Blunder - episode 2".
10+
711
## [1.3.0] - 2022-03-02
812
### Added
913
- Tests for "Network cabling".
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* The "Blunder - episode 2" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
const room = readline();
8+
}
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('answer');
14+
}
15+
16+
export { execute };
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../File.js';
4+
import { execute } from '../../../../lib/training/hard/blunderEpisode2/blunderEpisode2.js';
5+
6+
/**
7+
* Tests for the "Blunder - episode 2" puzzle.
8+
*/
9+
suite('Blunder - episode 2', 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('One room', function() {
22+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/01 - one room.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
200
29+
);
30+
});
31+
32+
test('3 rooms', function() {
33+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/02 - 3 rooms.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
40
40+
);
41+
});
42+
43+
test('15 rooms, small range', function() {
44+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/03 - 15 rooms small range.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
88
51+
);
52+
});
53+
54+
test('55 rooms', function() {
55+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/04 - 55 rooms.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
358
62+
);
63+
});
64+
65+
test('1275 rooms', function() {
66+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/05 - 1275 rooms.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assert.strictEqual(
71+
console.log.getCall(0).args[0],
72+
1928
73+
);
74+
});
75+
76+
test('5050 rooms', function() {
77+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/06 - 5050 rooms.txt');
78+
79+
execute(inputFile.readline.bind(inputFile));
80+
81+
assert.strictEqual(
82+
console.log.getCall(0).args[0],
83+
75413
84+
);
85+
});
86+
87+
test('9870 rooms', function() {
88+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/07 - 9870 rooms.txt');
89+
90+
execute(inputFile.readline.bind(inputFile));
91+
92+
assert.strictEqual(
93+
console.log.getCall(0).args[0],
94+
103558
95+
);
96+
});
97+
98+
test('Square building', function() {
99+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/08 - square building.txt');
100+
101+
execute(inputFile.readline.bind(inputFile));
102+
103+
assert.strictEqual(
104+
console.log.getCall(0).args[0],
105+
400
106+
);
107+
});
108+
109+
test('Multiple entries', function() {
110+
let inputFile = new File('./test/training/hard/blunderEpisode2/input/09 - multiple entries.txt');
111+
112+
execute(inputFile.readline.bind(inputFile));
113+
114+
assert.strictEqual(
115+
console.log.getCall(0).args[0],
116+
358
117+
);
118+
});
119+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
0 200 E E
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
0 20 1 2
3+
1 17 E E
4+
2 20 E E
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15
2+
0 17 1 2
3+
1 15 3 4
4+
2 15 4 5
5+
3 20 6 7
6+
4 12 7 8
7+
5 11 8 9
8+
6 18 10 11
9+
7 19 11 12
10+
8 12 12 13
11+
9 11 13 14
12+
10 13 E E
13+
11 14 E E
14+
12 17 E E
15+
13 19 E E
16+
14 15 E E
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
55
2+
0 46 1 2
3+
1 29 3 4
4+
2 26 4 5
5+
3 34 6 7
6+
4 36 7 8
7+
5 10 8 9
8+
6 21 10 11
9+
7 21 11 12
10+
8 12 12 13
11+
9 16 13 14
12+
10 21 15 16
13+
11 22 16 17
14+
12 38 17 18
15+
13 34 18 19
16+
14 49 19 20
17+
15 21 21 22
18+
16 37 22 23
19+
17 38 23 24
20+
18 31 24 25
21+
19 42 25 26
22+
20 21 26 27
23+
21 48 28 29
24+
22 24 29 30
25+
23 14 30 31
26+
24 23 31 32
27+
25 40 32 33
28+
26 11 33 34
29+
27 22 34 35
30+
28 25 36 37
31+
29 11 37 38
32+
30 13 38 39
33+
31 16 39 40
34+
32 43 40 41
35+
33 24 41 42
36+
34 47 42 43
37+
35 46 43 44
38+
36 15 45 46
39+
37 36 46 47
40+
38 36 47 48
41+
39 31 48 49
42+
40 17 49 50
43+
41 27 50 51
44+
42 22 51 52
45+
43 46 52 53
46+
44 19 53 54
47+
45 34 E E
48+
46 21 E E
49+
47 14 E E
50+
48 16 E E
51+
49 25 E E
52+
50 47 E E
53+
51 37 E E
54+
52 39 E E
55+
53 38 E E
56+
54 32 E E

0 commit comments

Comments
 (0)