Skip to content

Commit f033472

Browse files
committed
Adding tests for "Plight of the fellowship
of the ring".
1 parent 73bd421 commit f033472

File tree

8 files changed

+204
-0
lines changed

8 files changed

+204
-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 "Bit count to limit".
3333
- Tests for "Porcupine fever".
3434
- Tests for "Bijective numeration".
35+
- Tests for "Plight of the fellowship of the ring".
3536

3637
## [1.15.0] - 2022-11-30
3738
### Added
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* The "Plight of the fellowship of the ring" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/plight-of-the-fellowship-of-the-ring}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
const M = parseInt(readline());
8+
const L = parseInt(readline());
9+
for (let i = 0; i < N; i++) {
10+
var inputs = readline().split(' ');
11+
const XS = parseInt(inputs[0]);
12+
const YS = parseInt(inputs[1]);
13+
}
14+
for (let i = 0; i < M; i++) {
15+
var inputs = readline().split(' ');
16+
const XO = parseInt(inputs[0]);
17+
const YO = parseInt(inputs[1]);
18+
}
19+
for (let i = 0; i < L; i++) {
20+
var inputs = readline().split(' ');
21+
const N1 = parseInt(inputs[0]);
22+
const N2 = parseInt(inputs[1]);
23+
}
24+
const S = parseInt(readline());
25+
const E = parseInt(readline());
26+
27+
// Write an answer using console.log()
28+
// To debug: console.error('Debug messages...');
29+
30+
console.log('path');
31+
}
32+
33+
export { execute };
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/plightOfTheFellowshipOfTheRing/plightOfTheFellowshipOfTheRing.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Plight of the fellowship of the ring", 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("One orc", function() {
21+
let inputFile = new File(__dirname + 'input/01 - one orc.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"0 1 3"
28+
);
29+
});
30+
31+
test("Multiple orcs", function() {
32+
let inputFile = new File(__dirname + 'input/02 - multiple orcs.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"0 1 3 4 6"
39+
);
40+
});
41+
42+
test("Many choices", function() {
43+
let inputFile = new File(__dirname + 'input/03 - many choices.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"0 1 2 8 9 10 11 7"
50+
);
51+
});
52+
53+
test("Impossible", function() {
54+
let inputFile = new File(__dirname + 'input/04 - impossible.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"IMPOSSIBLE"
61+
);
62+
});
63+
64+
test("No orcs!", function() {
65+
let inputFile = new File(__dirname + 'input/05 - no orcs!.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"0 2 3"
72+
);
73+
});
74+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
4
2+
1
3+
4
4+
1 1
5+
2 0
6+
2 2
7+
3 1
8+
1 2
9+
0 1
10+
0 2
11+
1 3
12+
2 3
13+
0
14+
3
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
9
2+
3
3+
9
4+
0 0
5+
3 0
6+
5 -2
7+
5 2
8+
8 2
9+
8 -2
10+
10 0
11+
10 4
12+
3 4
13+
8 -4
14+
1 4
15+
10 8
16+
0 1
17+
1 2
18+
1 3
19+
2 5
20+
3 4
21+
5 6
22+
4 7
23+
4 6
24+
3 8
25+
0
26+
6
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
12
2+
2
3+
13
4+
0 0
5+
3 0
6+
5 -2
7+
5 2
8+
8 2
9+
8 -2
10+
10 0
11+
-2 10
12+
5 -5
13+
-3 -5
14+
-3 0
15+
-3 5
16+
5 4
17+
12 5
18+
0 1
19+
1 2
20+
1 3
21+
2 5
22+
3 6
23+
5 6
24+
6 4
25+
4 7
26+
2 8
27+
8 9
28+
9 10
29+
10 11
30+
11 7
31+
0
32+
7
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
3
2+
1
3+
2
4+
0 0
5+
3 0
6+
5 2
7+
5 3
8+
0 1
9+
1 2
10+
0
11+
2
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
4
2+
0
3+
4
4+
1 1
5+
2 2
6+
2 0
7+
3 1
8+
0 1
9+
0 2
10+
1 2
11+
2 3
12+
0
13+
3

0 commit comments

Comments
 (0)