Skip to content

Commit 7118c8c

Browse files
committed
Adding tests for "Sweet spot".
1 parent 49699de commit 7118c8c

19 files changed

+368
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Tests for "Are the clumps normal".
3434
- Tests for "Bulk email generator".
3535
- Tests for "Snail run".
36+
- Tests for "Sweet spot".
3637

3738
### Changed
3839
- Docker Node image from "14.16.1-alpine" to "node:16.14.2-alpine".
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "Sweet spot" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/sweet-spot}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
const line = readline();
9+
}
10+
11+
// Write an answer using console.log()
12+
// To debug: console.error('Debug messages...');
13+
14+
console.log('answer');
15+
}
16+
17+
export { execute };
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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/easy/sweetSpot/sweetSpot.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Sweet spot", 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("First attempt with A-bomb", function() {
22+
let inputFile = new File(__dirname + 'input/01 - first attempt with a-bomb.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - first attempt with a-bomb.txt');
27+
});
28+
29+
test("First attempt with H-bomb", function() {
30+
let inputFile = new File(__dirname + 'input/02 - first attempt with h-bomb.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - first attempt with h-bomb.txt');
35+
});
36+
37+
test("Real case : A/H-bomb", function() {
38+
let inputFile = new File(__dirname + 'input/03 - real case : A H-bomb.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - real case : A H-bomb.txt');
43+
});
44+
45+
test("First attempt with B-bomb", function() {
46+
let inputFile = new File(__dirname + 'input/04 - first attempt with b-bomb.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - first attempt with b-bomb.txt');
51+
});
52+
53+
test("Small map", function() {
54+
let inputFile = new File(__dirname + 'input/05 - small map.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - small map.txt');
59+
});
60+
61+
test("Real case : all bombs", function() {
62+
let inputFile = new File(__dirname + 'input/06 - real case : all bombs.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - real case : all bombs.txt');
67+
});
68+
69+
test("Damaged map", function() {
70+
let inputFile = new File(__dirname + 'input/07 - damaged map.txt');
71+
72+
execute(inputFile.readline.bind(inputFile));
73+
74+
assertOutputAnswer(__dirname + 'output/07 - damaged map.txt');
75+
});
76+
77+
test("No explosions", function() {
78+
let inputFile = new File(__dirname + 'input/08 - no explosions.txt');
79+
80+
execute(inputFile.readline.bind(inputFile));
81+
82+
assertOutputAnswer(__dirname + 'output/08 - no explosions.txt');
83+
});
84+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15
2+
000000000000000
3+
A00A0000000000A
4+
000000000000000
5+
000000000000000
6+
000000000000000
7+
000000000000000
8+
000000000000000
9+
000000000000000
10+
0000000A0000000
11+
000000000000000
12+
000000000000000
13+
000000000000000
14+
000000000000000
15+
000000000000000
16+
A000000000000AA
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
18
2+
H00000000000000000
3+
000000000000000H00
4+
000000000000000000
5+
00000000H000000000
6+
000000000000000000
7+
000000000000000000
8+
000000000000000000
9+
000000HH0000000000
10+
000000000000000000
11+
000000000000000000
12+
000000000000000H00
13+
000000000000000000
14+
000000000000000000
15+
000000000000000000
16+
HHH00000000H000000
17+
000000000000000000
18+
000000000000000000
19+
000000000000000000
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
22
2+
0000000000000000000000
3+
0000000000000000000000
4+
0000000AAHAA0000000000
5+
0000000000000000000000
6+
0000000000000000000000
7+
000000000000000000000A
8+
0000000000000000000000
9+
0000000000000000000000
10+
000A000000000000000000
11+
000000000HAH0000A00000
12+
0000000000000000000000
13+
A000000000000000000000
14+
A000000000000000000000
15+
0000000000000000000000
16+
0000000000000000000000
17+
0000000000000000000000
18+
A000000000000000000H00
19+
0000000000000000000000
20+
0000000000A00000000000
21+
0000000000000000000000
22+
0000000000000000000000
23+
H00000000000000000000A
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
22
2+
000000000000000000000A
3+
00000B0000000000000000
4+
0000000000000000000000
5+
0B0000000000000000000B
6+
000000000000000000B000
7+
0000000000000000000000
8+
000000000000000000000B
9+
0000000000000000000000
10+
000000B00000000A000000
11+
000000000000000000000B
12+
0000000000000000000000
13+
000000B000000000000000
14+
000000000000000000000B
15+
0000000000000000000000
16+
000000000H000000000000
17+
000000000000000000000B
18+
0000000000000000000000
19+
A000000000000000000000
20+
A00000000000B000000000
21+
A000000000000000000000
22+
HHHH00000000000000A00H
23+
00000000A0000000000000
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
00000
3+
00000
4+
00A00
5+
00000
6+
00000
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
25
2+
0000000000000000000000000
3+
00000000000HHH00000000H00
4+
00H0000000000000000000000
5+
0000000000000000000000000
6+
0000000000000000000000000
7+
00000000000000000000A0000
8+
000000000000000B000000000
9+
00000H0000A00000000000000
10+
00000000000000000000H0000
11+
0000000000000000000000000
12+
0000000000000000000000000
13+
00A0000000000000000000000
14+
0000000000000000000000000
15+
00000B0000000000000000000
16+
0000000000000000000000000
17+
0000000000000000000A00000
18+
00000B00BBB00000000000000
19+
0000000000000000000000000
20+
0A00000000000000000000000
21+
0000000000000000000000000
22+
0000000000000000000000000
23+
000000000000A000000000000
24+
0000000000000000000000000
25+
000B000000000000000000000
26+
000000000000000000000H000
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15
2+
A07000000000000
3+
007000070000000
4+
777003009000000
5+
00000000000000A
6+
000000000000000
7+
000000000000000
8+
004000009000000
9+
0000A00H0000000
10+
006000000000000
11+
000000080000000
12+
A00000000000000
13+
000000000000000
14+
000000000000030
15+
000000000000000
16+
00100000H000000

0 commit comments

Comments
 (0)