Skip to content

Commit ffe3861

Browse files
committed
Adding tests for "Magic stones".
1 parent 9261dda commit ffe3861

File tree

10 files changed

+129
-0
lines changed

10 files changed

+129
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- Tests for "Byte pair encoding".
3030
- Tests for "Find the missing plus signs in addition".
3131
- Tests for "Rod cutting problem".
32+
- Tests for "Magic stones".
3233

3334
## [1.13.0] - 2022-09-30
3435
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Magic stones" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/magic-stones}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
var inputs = readline().split(' ');
8+
for (let i = 0; i < N; i++) {
9+
const level = parseInt(inputs[i]);
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('1');
16+
}
17+
18+
export { execute };
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/magicStones/magicStones.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Magic stones", 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("Axiom", function() {
21+
let inputFile = new File(__dirname + 'input/01 - axiom.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("Add me up", function() {
32+
let inputFile = new File(__dirname + 'input/02 - add me up.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
1
39+
);
40+
});
41+
42+
test("Too far", function() {
43+
let inputFile = new File(__dirname + 'input/03 - too far.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
2
50+
);
51+
});
52+
53+
test("Odd", function() {
54+
let inputFile = new File(__dirname + 'input/04 - odd.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
5
61+
);
62+
});
63+
64+
test("Powerless", function() {
65+
let inputFile = new File(__dirname + 'input/05 - powerless.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
4
72+
);
73+
});
74+
75+
test("Complex", function() {
76+
let inputFile = new File(__dirname + 'input/06 - complex.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
2
83+
);
84+
});
85+
86+
test("Huge", function() {
87+
let inputFile = new File(__dirname + 'input/07 - huge.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
12
94+
);
95+
});
96+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
1 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1 2 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1 1 5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
9
2+
1 1 1 2 2 3 3 4 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
1 2 3 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
16
2+
1 1 2 3 3 3 5 6 6 6 6 6 6 6 6 9
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1000
2+
1 8 7 3 18 7 15 14 6 13 4 12 7 4 10 5 19 10 13 11 14 13 13 6 9 11 5 17 12 4 17 13 1 11 13 20 11 9 14 16 14 11 5 9 9 2 12 3 15 8 10 11 19 10 13 15 5 7 2 20 16 19 8 14 2 14 20 12 3 19 15 1 11 4 6 9 10 7 17 13 3 19 1 16 10 2 20 7 15 3 10 12 19 8 5 4 2 15 13 10 16 19 11 15 13 9 5 12 8 11 10 1 4 14 5 11 15 4 6 12 12 2 16 17 15 6 3 17 4 8 2 2 18 18 14 11 8 15 16 2 3 7 6 12 9 7 12 19 17 3 10 3 4 19 16 18 2 9 7 3 3 6 16 3 16 20 2 11 3 4 4 7 13 12 14 19 6 5 20 6 4 20 4 11 6 20 8 7 9 5 5 11 16 19 9 4 15 12 12 16 20 20 4 18 17 12 3 18 5 15 18 6 15 11 20 19 9 17 2 2 17 10 19 10 14 13 10 15 9 4 2 16 15 12 14 11 18 10 16 9 16 4 14 10 1 15 14 2 5 8 2 18 18 8 14 8 12 12 18 8 12 5 2 14 20 7 3 4 18 6 15 1 2 18 12 18 5 3 11 19 7 7 13 6 13 18 4 16 2 2 8 15 2 6 11 12 19 6 18 5 15 18 2 12 15 8 10 15 15 16 16 7 5 7 3 10 14 17 3 18 20 14 6 19 16 5 9 17 12 16 19 6 19 18 12 6 14 9 8 9 12 20 20 14 11 19 10 10 14 4 5 14 14 6 7 13 17 10 3 14 19 19 14 12 4 7 19 4 2 5 8 14 20 17 4 20 12 7 10 9 11 9 17 3 4 2 9 11 8 7 6 10 8 10 6 9 6 7 15 19 17 20 9 6 19 2 8 18 14 16 1 18 4 13 18 10 17 14 19 5 16 3 4 14 19 15 14 15 19 7 20 16 7 9 18 7 7 14 15 6 13 2 6 18 16 19 19 10 5 5 13 6 3 16 7 4 16 8 1 11 10 4 18 3 5 5 5 6 3 10 3 20 15 2 14 8 10 5 16 15 7 19 2 7 9 18 13 12 7 14 8 7 9 13 2 11 7 15 19 3 17 6 7 12 4 12 11 14 19 2 11 8 3 15 8 14 8 13 16 13 4 4 11 4 12 12 12 19 3 3 19 11 18 5 18 16 18 18 1 13 18 19 8 8 7 6 7 14 7 2 16 17 2 12 2 15 6 13 11 17 13 7 2 13 10 14 13 14 14 11 4 6 20 17 11 14 3 11 16 17 10 10 13 8 5 9 16 17 15 14 8 2 7 5 10 16 3 7 13 7 11 11 10 11 17 19 11 15 16 7 14 1 2 16 11 3 2 15 10 16 17 8 16 19 14 3 4 9 4 3 8 16 16 15 13 3 1 9 19 16 17 9 7 6 16 6 15 13 3 18 15 18 12 4 9 7 6 15 6 9 13 4 10 7 4 20 10 11 18 14 2 13 13 10 3 5 14 6 15 7 15 7 7 16 12 12 6 20 4 1 4 6 3 12 9 18 13 4 9 10 2 15 13 9 14 9 2 16 20 9 6 4 13 17 18 20 5 9 7 8 1 5 3 8 3 15 11 1 15 1 13 14 19 17 9 4 4 14 6 12 14 9 5 8 6 16 4 13 4 3 13 14 18 18 8 1 15 2 6 4 2 5 14 14 15 19 3 14 14 5 2 16 2 14 11 1 16 12 17 8 18 4 16 3 15 13 17 19 4 14 8 1 7 15 17 15 5 11 5 13 9 10 14 11 15 11 17 8 11 18 3 1 12 12 14 17 16 7 15 11 15 1 3 10 2 18 5 16 9 2 7 19 3 19 15 5 6 12 4 6 4 13 15 16 13 9 11 16 3 20 5 9 3 15 2 15 8 19 20 6 13 4 4 10 16 6 7 6 10 6 7 4 8 11 13 9 16 18 20 14 18 8 11 7 11 11 9 2 10 9 12 20 7 14 8 13 9 6 10 16 18 13 16 8 10 10 18 18 5 11 9 1 2 6 10 19 6 4 3 8 20 2 20 17 1 6 15 14 17 3 7 12 16 2 12 5 5 16 15 16 15 6 11 14 3 7 12 19 13 15 11 7 6 12 18 12 5 4 8 19 8 9 18 19 4 14 3 8 13 8 10 2 16 9 14 11 17 16 14 18 9 6 15 5 13 16 9 18 18 5 6 10 5 14 3 9 20 9 6 14

0 commit comments

Comments
 (0)