Skip to content

Commit 7ff507a

Browse files
committed
Adding tests for "Porcupine fever".
1 parent c8fc9e4 commit 7ff507a

File tree

12 files changed

+704
-0
lines changed

12 files changed

+704
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Tests for "Texas holdem".
3131
- Tests for "Solid integer".
3232
- Tests for "Bit count to limit".
33+
- Tests for "Porcupine fever".
3334

3435
## [1.15.0] - 2022-11-30
3536
### Added
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* The "Porcupine fever" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/porcupine-fever}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
const Y = parseInt(readline());
8+
for (let i = 0; i < N; i++) {
9+
var inputs = readline().split(' ');
10+
const S = parseInt(inputs[0]);
11+
const H = parseInt(inputs[1]);
12+
const A = parseInt(inputs[2]);
13+
}
14+
for (let i = 0; i < Y; i++) {
15+
16+
// Write an answer using console.log()
17+
// To debug: console.error('Debug messages...');
18+
19+
console.log('answer');
20+
}
21+
}
22+
23+
export { execute };
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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/medium/porcupineFever/porcupineFever.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Porcupine fever", 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 sick cage", function() {
22+
let inputFile = new File(__dirname + 'input/01 - one sick cage.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - one sick cage.txt');
27+
});
28+
29+
test("No porcupines", function() {
30+
let inputFile = new File(__dirname + 'input/02 - no porcupines.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assert.strictEqual(
35+
console.log.getCall(0).args[0],
36+
0
37+
);
38+
});
39+
40+
test("One cage goes extinct", function() {
41+
let inputFile = new File(__dirname + 'input/03 - one cage goes extinct.txt');
42+
43+
execute(inputFile.readline.bind(inputFile));
44+
45+
assertOutputAnswer(__dirname + 'output/03 - one cage goes extinct.txt');
46+
});
47+
48+
test("Dead farm", function() {
49+
let inputFile = new File(__dirname + 'input/04 - dead farm.txt');
50+
51+
execute(inputFile.readline.bind(inputFile));
52+
53+
assertOutputAnswer(__dirname + 'output/04 - dead farm.txt');
54+
});
55+
56+
test("Bigger farm", function() {
57+
let inputFile = new File(__dirname + 'input/05 - bigger farm.txt');
58+
59+
execute(inputFile.readline.bind(inputFile));
60+
61+
assertOutputAnswer(__dirname + 'output/05 - bigger farm.txt');
62+
});
63+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2
2+
3
3+
2 118 120
4+
0 50 50
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0
2+
1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
3
2+
3
3+
2 16 18
4+
6 8 14
5+
0 50 50
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
62
2+
26
3+
11 1 12
4+
7 1249 1256
5+
1 91 92
6+
57 1 58
7+
99 3621 3720
8+
85 1542 1627
9+
164 56 220
10+
30 1 31
11+
2 939 941
12+
36 1069 1105
13+
8 1199 1207
14+
174 13 187
15+
84 24 108
16+
2 8 10
17+
56 133 189
18+
57 218 275
19+
291 2125 2416
20+
11 5911 5922
21+
15 16 31
22+
5 8 13
23+
115 41 156
24+
25 11 36
25+
391 47 438
26+
11 15 26
27+
4 10 14
28+
195 820 1015
29+
37 7 44
30+
134 104 238
31+
47 1729 1776
32+
89 26 115
33+
1 3 4
34+
4 17 21
35+
6 3 9
36+
1 2210 2211
37+
3 4378 4381
38+
1 93 94
39+
78 18746 18824
40+
7 307 314
41+
4 1 5
42+
11 428 439
43+
8 2 10
44+
47 27 74
45+
5 99 104
46+
43 99 142
47+
1 125 126
48+
2 5870 5872
49+
2 87 89
50+
5 1 6
51+
45 26 71
52+
195 14 209
53+
5 19 24
54+
1 1 2
55+
5 9 14
56+
61 302 363
57+
1 159 160
58+
304 61 365
59+
4 48 52
60+
72 9624 9696
61+
14 43 57
62+
4 33 37
63+
6 46 52
64+
3 2 5

0 commit comments

Comments
 (0)