Skip to content

Commit 73bd421

Browse files
committed
Adding tests for "Bijective numeration".
1 parent 7ff507a commit 73bd421

File tree

12 files changed

+155
-0
lines changed

12 files changed

+155
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Tests for "Solid integer".
3232
- Tests for "Bit count to limit".
3333
- Tests for "Porcupine fever".
34+
- Tests for "Bijective numeration".
3435

3536
## [1.15.0] - 2022-11-30
3637
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Bijective numeration" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/bijective-numeration}
4+
*/
5+
function execute(readline) {
6+
const count = parseInt(readline());
7+
var inputs = readline().split(' ');
8+
for (let i = 0; i < count; i++) {
9+
const decimary = inputs[i];
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('summation');
16+
}
17+
18+
export { execute };
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/bijectiveNumeration/bijectiveNumeration.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Bijective numeration", 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("Simple parsing", function() {
21+
let inputFile = new File(__dirname + 'input/01 - simple parsing.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"32"
28+
);
29+
});
30+
31+
test("Parsing", function() {
32+
let inputFile = new File(__dirname + 'input/02 - parsing.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"234"
39+
);
40+
});
41+
42+
test("More parsing", function() {
43+
let inputFile = new File(__dirname + 'input/03 - more parsing.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"2345"
50+
);
51+
});
52+
53+
test("Simple generation", function() {
54+
let inputFile = new File(__dirname + 'input/04 - simple generation.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"A"
61+
);
62+
});
63+
64+
test("Generation", function() {
65+
let inputFile = new File(__dirname + 'input/05 - generation.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"A24"
72+
);
73+
});
74+
75+
test("More generation", function() {
76+
let inputFile = new File(__dirname + 'input/06 - more generation.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"AA"
83+
);
84+
});
85+
86+
test("Mixed test", function() {
87+
let inputFile = new File(__dirname + 'input/07 - mixed test.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"1AAA"
94+
);
95+
});
96+
97+
test("Bigger test", function() {
98+
let inputFile = new File(__dirname + 'input/08 - bigger test.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"9A3A"
105+
);
106+
});
107+
108+
test("Huge test", function() {
109+
let inputFile = new File(__dirname + 'input/09 - huge test.txt');
110+
111+
execute(inputFile.readline.bind(inputFile));
112+
113+
assert.strictEqual(
114+
console.log.getCall(0).args[0],
115+
"1344AA18A"
116+
);
117+
});
118+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
A A 12
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
9A A2 1A 12
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1AA A2A AA5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
1 2 3 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
8
2+
512 256 128 64 32 16 8 8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
19 91
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
99A 9A9 A1

0 commit comments

Comments
 (0)