Skip to content

Commit 7e490ff

Browse files
committed
Adding tests for "A child's play".
1 parent 9a80942 commit 7e490ff

File tree

14 files changed

+257
-0
lines changed

14 files changed

+257
-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 "Benford's law".
1515
- Tests for "7-segment scanner".
1616
- Tests for "Lumen".
17+
- Tests for "A child's play".
1718

1819
## [1.6.0] - 2022-03-11
1920
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "A child's play" puzzle.
3+
*/
4+
function execute(readline) {
5+
var inputs = readline().split(' ');
6+
const w = parseInt(inputs[0]);
7+
const h = parseInt(inputs[1]);
8+
const n = parseInt(readline());
9+
for (let i = 0; i < h; i++) {
10+
const line = readline();
11+
}
12+
13+
// Write an answer using console.log()
14+
// To debug: console.error('Debug messages...');
15+
16+
console.log('answer');
17+
}
18+
19+
export { execute };
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/benfordsLaw/benfordsLaw.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("A child's play", 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("Test example", function() {
21+
let inputFile = new File(__dirname + 'input/01 - test example.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"7 1"
28+
);
29+
});
30+
31+
test("Test real case", function() {
32+
let inputFile = new File(__dirname + 'input/02 - test real case.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"4 2"
39+
);
40+
});
41+
42+
test("Test 3", function() {
43+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"2 1"
50+
);
51+
});
52+
53+
test("Test 4", function() {
54+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"6 6"
61+
);
62+
});
63+
64+
test("Test 5", function() {
65+
let inputFile = new File(__dirname + 'input/05 - test 5.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"4 1"
72+
);
73+
});
74+
75+
test("Test 6", function() {
76+
let inputFile = new File(__dirname + 'input/06 - test 6.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"2 3"
83+
);
84+
});
85+
86+
test("Test 7", function() {
87+
let inputFile = new File(__dirname + 'input/07 - test 7.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"2 1"
94+
);
95+
});
96+
97+
test("Test 8", function() {
98+
let inputFile = new File(__dirname + 'input/08 - test 8.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"3 1"
105+
);
106+
});
107+
108+
test("Test 9", function() {
109+
let inputFile = new File(__dirname + 'input/09 - test 9.txt');
110+
111+
execute(inputFile.readline.bind(inputFile));
112+
113+
assert.strictEqual(
114+
console.log.getCall(0).args[0],
115+
"1 3"
116+
);
117+
});
118+
119+
test("Loop detection 1", function() {
120+
let inputFile = new File(__dirname + 'input/10 - loop detection 1.txt');
121+
122+
execute(inputFile.readline.bind(inputFile));
123+
124+
assert.strictEqual(
125+
console.log.getCall(0).args[0],
126+
"5 4"
127+
);
128+
});
129+
130+
test("Loop detection 2", function() {
131+
let inputFile = new File(__dirname + 'input/11 - loop detection 2.txt');
132+
133+
execute(inputFile.readline.bind(inputFile));
134+
135+
assert.strictEqual(
136+
console.log.getCall(0).args[0],
137+
"2 2"
138+
);
139+
});
140+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
12 6
2+
987
3+
...#........
4+
...........#
5+
............
6+
............
7+
..#O........
8+
..........#.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
12 8
2+
1234321
3+
....#.......
4+
........#...
5+
...........#
6+
...#O.......
7+
...#........
8+
.......#....
9+
...........#
10+
....#.......
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
14 10
2+
123456789
3+
..#...........
4+
....#..#......
5+
.#O.....#.....
6+
..............
7+
..............
8+
.......##...#.
9+
............#.
10+
.#........###.
11+
.#.#..........
12+
..............
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
16 10
2+
12321123212397
3+
...#...###......
4+
...............#
5+
.#..............
6+
...........#....
7+
................
8+
................
9+
..#O............
10+
.......####.....
11+
#...............
12+
###############.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
20 10
2+
1234567898765434
3+
...#.......#........
4+
.......#..........#.
5+
..#O........#.......
6+
......#.............
7+
....................
8+
........#......#....
9+
....................
10+
..#......#..........
11+
..............#.....
12+
..................#.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
6 5
2+
15
3+
######
4+
##...#
5+
#.O#.#
6+
#....#
7+
######
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
4 4
2+
2
3+
####
4+
#..#
5+
#O.#
6+
####

0 commit comments

Comments
 (0)