Skip to content

Commit 260d4d7

Browse files
committed
Adding tests for "Gravity tumbler".
1 parent 75785cf commit 260d4d7

File tree

15 files changed

+234
-0
lines changed

15 files changed

+234
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Tests for "Huffman code".
3333
- Tests for "Number of paths between 2 points".
3434
- Tests for "The lost child.Episode-1".
35+
- Tests for "Gravity tumbler".
3536

3637
## [1.12.0] - 2022-09-01
3738
### Added
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* The "Gravity tumbler" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/gravity-tumbler}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const width = parseInt(inputs[0]);
8+
const height = parseInt(inputs[1]);
9+
const count = parseInt(readline());
10+
for (let i = 0; i < height; i++) {
11+
const raster = readline();
12+
}
13+
14+
// Write an answer using console.log()
15+
// To debug: console.error('Debug messages...');
16+
17+
console.log('...');
18+
console.log('write ###');
19+
}
20+
21+
export { execute };
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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/gravityTumbler/gravityTumbler.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Gravity tumbler", 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("Tumble", function() {
22+
let inputFile = new File(__dirname + 'input/01 - tumble.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - tumble.txt');
27+
});
28+
29+
test("Double", function() {
30+
let inputFile = new File(__dirname + 'input/02 - double.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - double.txt');
35+
});
36+
37+
test("Triple", function() {
38+
let inputFile = new File(__dirname + 'input/03 - triple.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - triple.txt');
43+
});
44+
45+
test("Whee!", function() {
46+
let inputFile = new File(__dirname + 'input/04 - whee!.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - whee!.txt');
51+
});
52+
53+
test("CodinGame 1", function() {
54+
let inputFile = new File(__dirname + 'input/05 - CodinGame 1.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - CodinGame 1.txt');
59+
});
60+
61+
test("CodinGame 2", function() {
62+
let inputFile = new File(__dirname + 'input/06 - CodinGame 2.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - CodinGame 2.txt');
67+
});
68+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
1
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
2
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
3
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
4
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
53 5
2+
38
3+
#.....#...#.#.......#...#...#.#.....#...#.#...#.#....
4+
#.....#...#.#.......#...#...#.#..#..#...#.#...#.#....
5+
#.....#...#.#...#...#...#...#.#.##..#...#.#...#.###..
6+
#####.#####.#####.#####.#...#.#####.#####.#...#.#####
7+
#####.#####.#####.#####.#####.#####.#####.#####.#####
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
53 5
2+
27
3+
#.....#...#.#.......#...#...#.#.....#...#.#...#.#....
4+
#.....#...#.#.......#...#...#.#..#..#...#.#...#.#....
5+
#.....#...#.#...#...#...#...#.#.##..#...#.#...#.###..
6+
#####.#####.#####.#####.#...#.#####.#####.#...#.#####
7+
#####.#####.#####.#####.#####.#####.#####.#####.#####
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
....#
2+
....#
3+
....#
4+
....#
5+
....#
6+
...##
7+
...##
8+
...##
9+
...##
10+
...##
11+
...##
12+
..###
13+
..###
14+
..###
15+
..###
16+
..###
17+
..###

0 commit comments

Comments
 (0)