Skip to content

Commit 11003b1

Browse files
committed
Adding tests for "OneWay city".
1 parent 7fea6d7 commit 11003b1

File tree

10 files changed

+112
-0
lines changed

10 files changed

+112
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Tests for "Continued fractions".
3131
- Tests for "All operations are equal!".
3232
- Tests for "Battle tower".
33+
- Tests for "OneWay city".
3334

3435
## [1.14.0] - 2022-10-31
3536
### Added
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* The "OneWay city" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/oneway-city}
4+
*/
5+
function execute(readline) {
6+
const M = parseInt(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('answer');
13+
}
14+
15+
export { execute };
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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/oneWayCity/oneWayCity.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("OneWay city", 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("Small village", function() {
22+
let inputFile = new File(__dirname + 'input/01 - small village.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
20
29+
);
30+
});
31+
32+
test("One way", function() {
33+
let inputFile = new File(__dirname + 'input/02 - one way.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
1
40+
);
41+
});
42+
43+
test("Small city", function() {
44+
let inputFile = new File(__dirname + 'input/03 - small city.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
497420
51+
);
52+
});
53+
54+
test("20th century", function() {
55+
let inputFile = new File(__dirname + 'input/04 - 20th century.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
"450883717216034179"
62+
);
63+
});
64+
65+
test("Conurbation", function() {
66+
let inputFile = new File(__dirname + 'input/05 - conurbation.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assert.strictEqual(
71+
console.log.getCall(0).args[0],
72+
"1400749509083708812152608657850239525991600"
73+
);
74+
});
75+
76+
test("Megalopolis", function() {
77+
let inputFile = new File(__dirname + 'input/06 - megalopolis.txt');
78+
79+
execute(inputFile.readline.bind(inputFile));
80+
81+
assertOutputAnswer(__dirname + 'output/06 - megalopolis.txt');
82+
});
83+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
7
2+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
14
2+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
31
2+
33
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
71
2+
75
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4120
2+
4159
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3375715115287449357506276695064342488380607772551755615179105507804899059681248045620173540991745403362335992757673890092105471733335852706166956530312567334487282482558146587432741997335465472009296092581251339613828107226092250609313066612320150281858290534116070831303198081250139809112963741399399956944877203613353540095656327855513072538940092251883729434762613946137613323500530338626825440359769354370691751069047472210539975607808503988395595325708324022469875191407849075969164735400267273918876233448307487137015836937446405489953161986067724506470373623798715644046761476038236218179504474387495625741419675817420060672735058379381909675603055899102193674430654068847174877852977532039723553447911446099658509438932429148596823935835842373222571840596638888126485481614315239822441381898968768838389768594618361392738202666851323740472500471213191622828935067038056874631138813798341429823849339329564142726906040118599910681472601453825831633755475584930282068833152447251261357850999727

0 commit comments

Comments
 (0)