Skip to content

Commit c3112b0

Browse files
committed
Adding tests for "A mountain of a mole hill".
1 parent 21d8a8f commit c3112b0

File tree

11 files changed

+251
-0
lines changed

11 files changed

+251
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Tests for "Rotating arrows".
3333
- Tests for "10 pin bowling scores".
3434
- Tests for "Is the king in check? (part 1)".
35+
- Tests for "A mountain of a mole hill".
3536

3637
### Fixed
3738
- File import for "A child's play".
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* The "A mountain of a mole hill" puzzle.
3+
*/
4+
function execute(readline) {
5+
for (let i = 0; i < 16; i++) {
6+
const line = readline();
7+
}
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
console.log('answer');
13+
}
14+
15+
export { execute };
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/aMountainOfAMoleHill/aMountainOfAMoleHill.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("A simple garden", function() {
9+
const sandbox = sinon.createSandbox();
10+
11+
setup(function () {
12+
sandbox.stub(console, "log");
13+
});
14+
15+
teardown(function () {
16+
sandbox.restore();
17+
});
18+
19+
20+
test("Test example", function() {
21+
let inputFile = new File(__dirname + 'input/01 - a simple garden.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
2
28+
);
29+
});
30+
31+
test("From another angle", function() {
32+
let inputFile = new File(__dirname + 'input/02 - from another angle.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
3
39+
);
40+
});
41+
42+
test("Getting crowded", function() {
43+
let inputFile = new File(__dirname + 'input/03 - getting crowded.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
10
50+
);
51+
});
52+
53+
test("Divide and conquer", function() {
54+
let inputFile = new File(__dirname + 'input/04 - divide and conquer.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
9
61+
);
62+
});
63+
64+
test("Bag of snakes", function() {
65+
let inputFile = new File(__dirname + 'input/05 - bag of snakes.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
13
72+
);
73+
});
74+
75+
test("Zzzzz...", function() {
76+
let inputFile = new File(__dirname + 'input/06 - zzzzz....txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
5
83+
);
84+
});
85+
86+
test("Include and infiltrate", function() {
87+
let inputFile = new File(__dirname + 'input/07 - Include and infiltrate.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
20
94+
);
95+
});
96+
97+
test("How did THAT happen?", function() {
98+
let inputFile = new File(__dirname + 'input/08 - how did THAT happen.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
74
105+
);
106+
});
107+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
................
2+
................
3+
..+----------+..
4+
..| |..
5+
..| o |..
6+
..| o |..
7+
..| |..
8+
..+----------+..
9+
................
10+
............o...
11+
.....o..........
12+
................
13+
.........o......
14+
................
15+
................
16+
................
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
................
2+
................
3+
...+-------+.o..
4+
.o.| o o |..o.
5+
...| |....
6+
...| o +--+.oo.
7+
...| |.......
8+
...+----+.......
9+
................
10+
........oo......
11+
................
12+
...o............
13+
................
14+
...........o....
15+
................
16+
................
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
................
2+
................
3+
.oo.+------+oooo
4+
.oo.| o |.oo.
5+
oooo|oooooo|....
6+
....+--+ o |.oo.
7+
.......| o |....
8+
....oo.|o ++.oo.
9+
....oo.+--+o.oo.
10+
................
11+
......ooo.......
12+
................
13+
................
14+
................
15+
................
16+
................
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
+--+....o..o....
2+
| o|............
3+
| |......o.....
4+
|o +---+........
5+
| |....+--+
6+
| o |....|oo|
7+
| |....|oo|
8+
+------+..o.+--+
9+
................
10+
.....oo.........
11+
................
12+
+--------------+
13+
| o |
14+
| o |
15+
| |
16+
+--------------+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.....o..........
2+
.+-------+..o.o.
3+
.| |.oo...
4+
.| o |ooooo.
5+
.| |oo....
6+
.|oo+-+oo+--+oo.
7+
.| |.| |o..
8+
.| |.| +-+.
9+
.|oo|o| |.
10+
.| |.| |.
11+
.| |.|ooo o|.
12+
.| |.| |.
13+
.| |.| oo |.
14+
.| |.| |.
15+
.+--+o+-------+.
16+
...............o
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
+--------------+
2+
| o o |
3+
+----------+ ++
4+
..........++ ++.
5+
....o....++ ++..
6+
........++ ++...
7+
.......++ ++....
8+
.oo...++o++...o.
9+
.....++ ++......
10+
....++ ++.......
11+
...++ ++....oo..
12+
..++ ++....o....
13+
.++ ++..........
14+
++o +----------+
15+
| o |
16+
+--------------+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
+--------------+
2+
| o oo |
3+
| +----------+o|
4+
| |..........| |
5+
| |.+------+o|o|
6+
| |.| |.| |
7+
| |o| +--+o|.| |
8+
| |.| |oo|o|.| |
9+
| |.| +--+ |.| |
10+
| |.| oo |.| |
11+
| |.|oooooo|.| |
12+
| |.+------+o|o|
13+
|o|..........| |
14+
|o+----------+ |
15+
| o o |
16+
+--------------+

0 commit comments

Comments
 (0)