Skip to content

Commit 30884b6

Browse files
committed
Adding tests for "Annihilation".
1 parent 24c5d46 commit 30884b6

File tree

9 files changed

+237
-0
lines changed

9 files changed

+237
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Tests for "Stall tilt".
2727
- Tests for "What's so complex about Mandelbrot?".
2828
- Tests for "Auto pickup".
29+
- Tests for "Annihilation".
2930

3031
## [1.9.0] - 2022-06-01
3132
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "Annihilation" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/annihilation}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const H = parseInt(inputs[0]);
8+
const W = parseInt(inputs[1]);
9+
for (let i = 0; i < H; i++) {
10+
const line = readline();
11+
}
12+
13+
// Write an answer using console.log()
14+
// To debug: console.error('Debug messages...');
15+
16+
console.log('timesteps');
17+
}
18+
19+
export { execute };
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/annihilation/annihilation.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Annihilation", 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 1", function() {
21+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
1
28+
);
29+
});
30+
31+
test("Test 2", function() {
32+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
29
39+
);
40+
});
41+
42+
test("Test 3", function() {
43+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
42
50+
);
51+
});
52+
53+
test("Test 4", function() {
54+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
237
61+
);
62+
});
63+
64+
test("Test 5", function() {
65+
let inputFile = new File(__dirname + 'input/05 - test 5.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
1084
72+
);
73+
});
74+
75+
test("Test 6", function() {
76+
let inputFile = new File(__dirname + 'input/06 - test 6.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
2215
83+
);
84+
});
85+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5 5
2+
.....
3+
..v..
4+
.>.<.
5+
..^..
6+
.....
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5 6
2+
>.....
3+
......
4+
......
5+
......
6+
.....^
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
9 8
2+
.......>
3+
........
4+
<.>..<.^
5+
><.....^
6+
.^..v^..
7+
...v.>..
8+
.....^<.
9+
...>....
10+
<.^^...v
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
16 17
2+
..^.^>....v><.<..
3+
^..v.<v...vv.>.^.
4+
vv..>.v.<...v<<.^
5+
>.>^.<^..<..vvv.^
6+
>..^vv...<.<v..<.
7+
..>.^.<.<.>.>..>v
8+
..><.<>^v<v>^.<.>
9+
.<.<>......>v^.>.
10+
..^>.<>^..<..<>>.
11+
.>.^v<..>.^v<.>>v
12+
>>^v.^v^.<>.v>...
13+
>^^v>>><.^v>.....
14+
.^..>><>>^v<.v..^
15+
.>v....<>>>>^.<v<
16+
>v^.^v.>..^^^^<<.
17+
.v.v<..><.v^.^...
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
41 33
2+
.><<><<<>v>>><<.v^>v.v>.v<.^^><v^
3+
><.^v>^><<v>.v<><.vv>>.>v<.>v<v^^
4+
>.<v.^v.v.^..v.v.<<.v^>^^v^<^^<<.
5+
..^v...<vvv.<<v^v<vvv<vv.^^>>^.>^
6+
<<^^.<<vv>>v>>..v<>^<^v^<<..^<>^^
7+
>.<vv^<<^^<^.v><<<vv>.v^.^>>v^<v>
8+
<<<..^^^<<^.vvv^..><>>^^v<^^.^^>.
9+
>v>>^>^^^^<^<>>^<<^<v<.>>^<<.^>^.
10+
<>.^^.v^<.<^<vv.<.^>>>>><.<v<<^.>
11+
...^^.^.v.v.^..<^^>.<.v^<>..<<v>^
12+
<>vv>^.>vv.v^v^>.<v.vv<v.<<^^.^<>
13+
v^v>^><.>^<^^.<<^>.<.v><^<<.>><.<
14+
.v^>>v^<v.>v>.<<<>.<.^<v>v>v>vvv.
15+
<..vv<v.<><<.>>>.>>>^v.^.^<v>^^<v
16+
v^vv<.>v.<<.>>.v^^.^v^v.>v.<.vv><
17+
><^^<vv<vv<vv>^.<>^^v.^^.<vv>^^^<
18+
..^>.^.....<>^>v>^vvv.^>^..v.v>>.
19+
^^><v><^.>.^>v.^>vv.>^>.v>v.<<><<
20+
<.v^^<.>>^v<<<..>^v^.vv<v<v^^^>v>
21+
<^^.>><<>.v<.^^^v.^.v.^<^v<<><>^^
22+
^>><v>v.><>^vv<v.<.v^<>^.><<>^.>.
23+
.>^><.><^>><>>>vv^^^<<v><>><<v>.v
24+
vv.>v<.v<^<..v.vv<><<.^v><>vvv.<^
25+
>v^v<>vvv<.^^>v.<^><.>..>^.>><^^v
26+
v>^^vv><><>.vv^<.>..><.<<v<<>.v.^
27+
<v><.v..^<><v^^.<^<<<.>v^>><<.^^^
28+
.>^>>>^^^^^...>>>^..>.>>>.vv<..<>
29+
.v>^>.^^.^^.^>>>vvvv>v^v>>^<>^<^v
30+
.>>>v<^v^^<^<.><..^<<v.v<vv^v><.^
31+
<.<<^.<.^^vv^^.<<v^<^.v<v>..v.<..
32+
v.<>^.^>>v.v<vv^><<<v><<.<^<^^v.v
33+
><<<>vv>^^^<^vv.<<^.>^<.><>^v>><v
34+
.^v^v><>^.><<>^^^..v.v^^.v>v.^^.<
35+
<.^>..>v>.<>>^<.v...v..<<.>^>^.^v
36+
v.vv<v^v.>^<<v.>v>^>vv>><.vv<<><v
37+
>><v^<..>^>>.^<v>>v<.>>..><>.<v.<
38+
^>^^^.>^><.<vv>.v<<v<^.<vv..^.^><
39+
>^>vv>.v<<v>^^^><><v^>^<<<^^^>>^v
40+
.<>^<v.>.>v>^><>v..<^.<>vvv<<<^v.
41+
v.><^^<^<.v>^<<.>.<<<^>v.^^.^v.>.
42+
.vv>^<.v>>.v.^<vvv<><>v^^>vv>>^.<
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
50 49
2+
.^<.v^<>..<^v.^<^>..<vv^.<<v.^<vv>>>vvvv<^^v<^>vv
3+
>^v^>vv><^vv..><v<<^.v<<.^v>>>.v.v.>>.>>>^v.vv<>^
4+
.^.<^>^v.^v^^.v<v^.<.<^v<.v.^.><^v<^>v..>v>v.<<<>
5+
^^.vv^>>.>.<vvvvv>>.>>v>^.v^<^<.>v<>>.<^<>>..>^<.
6+
^><v.v><>><^^<>v><v<<>^v^v.^<^v<>v<.>v^vvv^>.><..
7+
>.<><.<v^.v.v^<>>.>.^.>^v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.^>^.v^^^>^.v>^>^>.<.>>.vv><<>v<v.>>>..>>v
50+
.^>^.>.<^.v^vv>..^>^.>^^><.><^^.v^^<...>>>^>^..^>
51+
>v<vvv<^^v^^v<<.>..>.>v>>>v^.<>><vv>><.v^v^..^<<.

0 commit comments

Comments
 (0)