Skip to content

Commit 7605878

Browse files
committed
Adding tests for "Stall tilt".
1 parent 894c079 commit 7605878

File tree

13 files changed

+200
-0
lines changed

13 files changed

+200
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- Tests for "Robot reach".
2424
- Tests for "IPv6 shortener".
2525
- Tests for "Zhiwei Sun squares".
26+
- Tests for "Stall tilt".
2627

2728
## [1.9.0] - 2022-06-01
2829
### Added
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* The "Stall tilt" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/stall-tilt}
4+
*/
5+
function execute(readline) {
6+
const n = parseInt(readline());
7+
const v = parseInt(readline());
8+
for (let i = 0; i < n; i++) {
9+
const speed = parseInt(readline());
10+
}
11+
for (let i = 0; i < v; i++) {
12+
const bends = parseInt(readline());
13+
}
14+
15+
// Write an answer using console.log()
16+
// To debug: console.error('Debug messages...');
17+
18+
console.log('answer');
19+
}
20+
21+
export { execute };
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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/stallTilt/stallTilt.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Stall tilt", 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("Example", function() {
22+
let inputFile = new File(__dirname + 'input/01 - example.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - example.txt');
27+
});
28+
29+
test("Stalling", function() {
30+
let inputFile = new File(__dirname + 'input/02 - stalling.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - stalling.txt');
35+
});
36+
37+
test("Real case", function() {
38+
let inputFile = new File(__dirname + 'input/03 - real case.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - real case.txt');
43+
});
44+
45+
test("Just a little one", function() {
46+
let inputFile = new File(__dirname + 'input/04 - just a little one.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - just a little one.txt');
51+
});
52+
53+
test("Duel", function() {
54+
let inputFile = new File(__dirname + 'input/05 - duel.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - duel.txt');
59+
});
60+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
8
2+
2
3+
56
4+
6
5+
2
6+
23
7+
9
8+
25
9+
41
10+
15
11+
40
12+
30
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
11
2+
3
3+
20
4+
15
5+
48
6+
13
7+
53
8+
33
9+
3
10+
37
11+
22
12+
42
13+
17
14+
160
15+
80
16+
20
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
11
2+
7
3+
25
4+
48
5+
35
6+
41
7+
26
8+
15
9+
32
10+
37
11+
9
12+
46
13+
6
14+
130
15+
120
16+
110
17+
100
18+
90
19+
80
20+
50
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
11
2+
1
3+
25
4+
17
5+
35
6+
11
7+
2
8+
15
9+
22
10+
56
11+
8
12+
46
13+
6
14+
5
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1
2+
1
3+
32
4+
60
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
22
2+
y
3+
h
4+
e
5+
b
6+
c
7+
f
8+
d
9+
a
10+
g
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
18
2+
y
3+
k
4+
b
5+
d
6+
g
7+
f
8+
i
9+
a
10+
c
11+
j
12+
h
13+
e

0 commit comments

Comments
 (0)