Skip to content

Commit 8b7042a

Browse files
committed
Adding tests for "Number of paths between 2
points".
1 parent 5d61389 commit 8b7042a

File tree

7 files changed

+117
-0
lines changed

7 files changed

+117
-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 "Chained matrix products".
3131
- Tests for "Fun with set theory".
3232
- Tests for "Huffman code".
33+
- Tests for "Number of paths between 2 points".
3334

3435
## [1.12.0] - 2022-09-01
3536
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Number of paths between 2 points" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/number-of-paths-between-2-points}
4+
*/
5+
function execute(readline) {
6+
const M = parseInt(readline());
7+
const N = parseInt(readline());
8+
for (let i = 0; i < M; i++) {
9+
const ROW = readline();
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
export { execute };
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/numberOfPathsBetween2Points/numberOfPathsBetween2Points.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Number of paths between 2 points", 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("Test 1", function() {
21+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
2
28+
);
29+
});
30+
31+
32+
test("Test 2", function() {
33+
let inputFile = new File(__dirname + 'input/02 - test 2.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+
44+
test("Test 3", function() {
45+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
46+
47+
execute(inputFile.readline.bind(inputFile));
48+
49+
assert.strictEqual(
50+
console.log.getCall(0).args[0],
51+
2716
52+
);
53+
});
54+
55+
56+
test("Test 4", function() {
57+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
58+
59+
execute(inputFile.readline.bind(inputFile));
60+
61+
assert.strictEqual(
62+
console.log.getCall(0).args[0],
63+
0
64+
);
65+
});
66+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2
2+
2
3+
00
4+
00
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2
2+
2
3+
00
4+
10
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
10
2+
10
3+
0000001000
4+
0000000000
5+
0000000000
6+
0010001000
7+
0000000000
8+
0000100000
9+
0000100010
10+
0000000000
11+
0000000100
12+
0000000010
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
10
2+
10
3+
0010001000
4+
0010000000
5+
0010000000
6+
1110001000
7+
0000000000
8+
0000100000
9+
0000100010
10+
0000000000
11+
0000000101
12+
0000000010

0 commit comments

Comments
 (0)