Skip to content

Commit 0449271

Browse files
committed
Adding tests for "Byte pair encoding".
1 parent c1e98f0 commit 0449271

File tree

13 files changed

+166
-0
lines changed

13 files changed

+166
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Tests for "Horse-hyperracing hyperduals".
2727
- Tests for "3×N tiling".
2828
- Tests for "Hexagonal maze - part2".
29+
- Tests for "Byte pair encoding".
2930

3031
## [1.13.0] - 2022-09-30
3132
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "Byte pair encoding" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/byte-pair-encoding}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const n = parseInt(inputs[0]);
8+
const m = parseInt(inputs[1]);
9+
for (let i = 0; i < n; 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: 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/medium/bytePairEncoding/bytePairEncoding.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Byte pair encoding", 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("Test 1", function() {
22+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - test 1.txt');
27+
});
28+
29+
test("Test 2", function() {
30+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - test 2.txt');
35+
});
36+
37+
test("Test 3", function() {
38+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - test 3.txt');
43+
});
44+
45+
test("Test 4", function() {
46+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - test 4.txt');
51+
});
52+
53+
test("Test 5", function() {
54+
let inputFile = new File(__dirname + 'input/05 - test 5.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - test 5.txt');
59+
});
60+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 11
2+
aaabdaaabac
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2 10
2+
aedcaafffb
3+
ddcaaacdcd
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4 10
2+
aaaaaaaaaa
3+
aaaaabbbbb
4+
bbbbbbbbbb
5+
cccccccccc
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
cdeaafdhhh
3+
cdecbfcbhf
4+
hdhhccfhed
5+
eadggchefh
6+
gcaffgdcag
7+
dfedaghgce
8+
afbdccegbf
9+
ggafhdffbh
10+
ahgadeabcc
11+
abhfgeceff
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 20
2+
bbhhehbhejhgeijaagjb
3+
eccfjaidghhcdjhadajb
4+
ejdffehjgbeejahcddae
5+
ciibfggbfbdifcafchcc
6+
jfaecjacccihgejjfbga
7+
acfegbhiigcfbeeibhji
8+
gighedcbcafacgcghjch
9+
cbjaiahfcaihdedijjja
10+
ffghhiabdgacafgghdai
11+
eicehcgjichccaeeafgb
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
XdXac
2+
Z = aa
3+
Y = Za
4+
X = Yb
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
aeXfffbdXacZd
2+
Z = dc
3+
Y = Za
4+
X = Ya

0 commit comments

Comments
 (0)