Skip to content

Commit f2e9382

Browse files
committed
Adding tests for "Robot show".
1 parent dc624cf commit f2e9382

File tree

9 files changed

+124
-0
lines changed

9 files changed

+124
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Tests for "1000000000D world".
1515
- Tests for "1D bush fire".
1616
- Tests for "Rectangle partition".
17+
- Tests for "Robot show".
1718

1819
## [1.4.0] - 2022-03-03
1920
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Robot show" puzzle.
3+
*/
4+
function execute(readline) {
5+
const L = parseInt(readline());
6+
const N = parseInt(readline());
7+
var inputs = readline().split(' ');
8+
for (let i = 0; i < N; i++) {
9+
const b = parseInt(inputs[i]);
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
export { execute };
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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/robotShow/robotShow.js';
6+
7+
/**
8+
* Tests for the "Robot show" puzzle.
9+
*/
10+
suite('Robot show', function() {
11+
const sandbox = sinon.createSandbox();
12+
13+
setup(function () {
14+
sandbox.stub(console, "log");
15+
});
16+
17+
teardown(function () {
18+
sandbox.restore();
19+
});
20+
21+
22+
test('Example', function() {
23+
let inputFile = new File('./test/community/training/easy/robotShow/input/01 - example.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assert.strictEqual(
28+
console.log.getCall(0).args[0],
29+
8
30+
);
31+
});
32+
33+
test('Simple', function() {
34+
let inputFile = new File('./test/community/training/easy/robotShow/input/02 - simple.txt');
35+
36+
execute(inputFile.readline.bind(inputFile));
37+
38+
assert.strictEqual(
39+
console.log.getCall(0).args[0],
40+
20
41+
);
42+
});
43+
44+
test('More Bots', function() {
45+
let inputFile = new File('./test/community/training/easy/robotShow/input/03 - more bots.txt');
46+
47+
execute(inputFile.readline.bind(inputFile));
48+
49+
assert.strictEqual(
50+
console.log.getCall(0).args[0],
51+
102
52+
);
53+
});
54+
55+
test('Ping Pong', function() {
56+
let inputFile = new File('./test/community/training/easy/robotShow/input/04 - ping pong.txt');
57+
58+
execute(inputFile.readline.bind(inputFile));
59+
60+
assert.strictEqual(
61+
console.log.getCall(0).args[0],
62+
112
63+
);
64+
});
65+
66+
test('Traffic Jam', function() {
67+
let inputFile = new File('./test/community/training/easy/robotShow/input/05 - traffic jam.txt');
68+
69+
execute(inputFile.readline.bind(inputFile));
70+
71+
assert.strictEqual(
72+
console.log.getCall(0).args[0],
73+
153
74+
);
75+
});
76+
77+
test('Singular', function() {
78+
let inputFile = new File('./test/community/training/easy/robotShow/input/06 - singular.txt');
79+
80+
execute(inputFile.readline.bind(inputFile));
81+
82+
assert.strictEqual(
83+
console.log.getCall(0).args[0],
84+
7
85+
);
86+
});
87+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10
2+
2
3+
2 6
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
20
2+
7
3+
1 2 20 7 6 10 14
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
103
2+
20
3+
87 19 72 59 22 74 89 30 33 3 66 77 15 23 58 82 56 98 1 84
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
113
2+
50
3+
42 38 102 73 106 15 51 8 72 66 112 95 87 90 1 104 25 43 14 29 57 98 33 58 55 16 49 60 105 71 18 12 28 86 4 101 63 36 22 31 45 17 75 85 32 61 62 30 107 13
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
156
2+
78
3+
14 127 21 15 91 121 89 105 32 136 100 95 143 112 88 147 78 48 36 114 28 33 151 9 59 11 116 134 6 39 67 50 110 102 139 49 118 30 144 4 97 56 52 73 125 115 149 66 71 42 3 61 141 81 106 101 99 137 111 133 79 43 145 84 51 107 131 12 87 104 60 126 119 146 96 7 94 10
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
14
2+
1
3+
7

0 commit comments

Comments
 (0)