Skip to content

Commit 344a6a3

Browse files
committed
Adding tests for "Next car license plate ?".
1 parent 130da65 commit 344a6a3

File tree

10 files changed

+126
-0
lines changed

10 files changed

+126
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Tests for "Largest number".
3535
- Tests for "Smooth!".
3636
- Tests for "2nd degree polynomial - simple analysis".
37+
- Tests for "Next car license plate ?".
3738

3839
## [1.9.0] - 2022-06-01
3940
### Added
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* The "Next car license plate ?" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/next-car-license-plate}
4+
*/
5+
function execute(readline) {
6+
const x = readline();
7+
const n = parseInt(readline());
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
console.log('AA-000-AA');
13+
}
14+
15+
export { execute };
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/nextCarLicensePlate/nextCarLicensePlate.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Next car license plate ?", 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("+5", function() {
21+
let inputFile = new File(__dirname + 'input/01 - +5.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"AB-128-CD"
28+
);
29+
});
30+
31+
test("+100", function() {
32+
let inputFile = new File(__dirname + 'input/02 - +100.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"AZ-666-QS"
39+
);
40+
});
41+
42+
test("999+1", function() {
43+
let inputFile = new File(__dirname + 'input/03 - 999+1.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"BN-001-GI"
50+
);
51+
});
52+
53+
test("+10000", function() {
54+
let inputFile = new File(__dirname + 'input/04 - +10000.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"CG-017-CQ"
61+
);
62+
});
63+
64+
test("+100000", function() {
65+
let inputFile = new File(__dirname + 'input/05 - +100000.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"IO-110-SE"
72+
);
73+
});
74+
75+
test("+1000000", function() {
76+
let inputFile = new File(__dirname + 'input/06 - +1000000.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"QT-457-PS"
83+
);
84+
});
85+
86+
test("Very big", function() {
87+
let inputFile = new File(__dirname + 'input/07 - very big.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"JQ-027-XY"
94+
);
95+
});
96+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AB-123-CD
2+
5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AZ-566-QS
2+
100
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BN-999-GH
2+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CG-007-CG
2+
10000
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
IO-010-OI
2+
100000
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QS-456-DF
2+
1000000
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ER-963-DF
2+
87654321

0 commit comments

Comments
 (0)