Skip to content

Commit 33b77fa

Browse files
committed
Adding tests for "DDCG mapper".
1 parent f033472 commit 33b77fa

File tree

11 files changed

+209
-0
lines changed

11 files changed

+209
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Tests for "Porcupine fever".
3434
- Tests for "Bijective numeration".
3535
- Tests for "Plight of the fellowship of the ring".
36+
- Tests for "DDCG Mapper".
3637

3738
## [1.15.0] - 2022-11-30
3839
### Added
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* The "DDCG mapper" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/ddcg-mapper}
4+
*/
5+
function execute(readline) {
6+
const L = parseInt(readline());
7+
const N = parseInt(readline());
8+
for (let i = 0; i < N; i++) {
9+
var inputs = readline().split(' ');
10+
const pattern = inputs[0];
11+
const tempo = parseInt(inputs[1]);
12+
}
13+
14+
// Write an answer using console.log()
15+
// To debug: console.error('Debug messages...');
16+
17+
console.log('answer');
18+
}
19+
20+
export { execute };
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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/DDCGMapper/DDCGMapper.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("DDCG mapper", 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("1", function() {
30+
let inputFile = new File(__dirname + 'input/02 - 1.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - 1.txt');
35+
});
36+
37+
test("2", function() {
38+
let inputFile = new File(__dirname + 'input/03 - 2.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - 2.txt');
43+
});
44+
45+
test("3", function() {
46+
let inputFile = new File(__dirname + 'input/04 - 3.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - 3.txt');
51+
});
52+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
7
2+
2
3+
X000 2
4+
00XX 3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
1
3+
X0X0 2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
12
2+
3
3+
X0X0 2
4+
0X0X 3
5+
0XX0 5
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
90
2+
9
3+
X000 2
4+
0X00 3
5+
00X0 5
6+
000X 4
7+
0XX0 11
8+
0X00 7
9+
XXXX 42
10+
00XX 16
11+
XX00 22
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
0000
2+
X0XX
3+
0000
4+
X000
5+
00XX
6+
X000
7+
0000
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
X0X0
2+
0000
3+
X0X0
4+
0000
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
XXXX
2+
0000
3+
XXX0
4+
0X0X
5+
X0X0
6+
0000
7+
XXXX
8+
0XX0
9+
X0X0
10+
0X0X
11+
X0X0
12+
0000

0 commit comments

Comments
 (0)