Skip to content

Commit d230e29

Browse files
committed
Adding tests for "Longest increasing
subsequence".
1 parent bb66616 commit d230e29

File tree

8 files changed

+2766
-0
lines changed

8 files changed

+2766
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- Tests for "1010(1)".
3636
- Tests for "Vote counting".
3737
- Tests for "Maze for the champions".
38+
- Tests for "Longest increasing subsequence".
3839

3940
## [1.16.0] - 2022-12-31
4041
### Added
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "Longest increasing subsequence" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/longest-increasing-subsequence}
4+
*/
5+
function execute(readline) {
6+
const n = parseInt(readline());
7+
for (let i = 0; i < n; i++) {
8+
const p = parseInt(readline());
9+
}
10+
11+
// Write an answer using console.log()
12+
// To debug: console.error('Debug messages...');
13+
14+
console.log('answer');
15+
}
16+
17+
export { execute };
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/longestIncreasingSubsequence/longestIncreasingSubsequence.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Longest increasing subsequence", 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", function() {
21+
let inputFile = new File(__dirname + 'input/01 - simple.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
4
28+
);
29+
});
30+
31+
test("Still simple", function() {
32+
let inputFile = new File(__dirname + 'input/02 - still simple.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
2
39+
);
40+
});
41+
42+
test("Medium", function() {
43+
let inputFile = new File(__dirname + 'input/03 - medium.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
7
50+
);
51+
});
52+
53+
test("Getting harder", function() {
54+
let inputFile = new File(__dirname + 'input/04 - getting harder.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
15
61+
);
62+
});
63+
64+
test("Lots of numbers!", function() {
65+
let inputFile = new File(__dirname + 'input/05 - lots of numbers!.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
94
72+
);
73+
});
74+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
5
3+
2
4+
8
5+
6
6+
3
7+
6
8+
9
9+
7
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
9
3+
2
4+
9
5+
8
6+
8
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
23
2+
44
3+
25
4+
29
5+
44
6+
1
7+
15
8+
19
9+
34
10+
37
11+
19
12+
12
13+
26
14+
20
15+
32
16+
45
17+
5
18+
3
19+
48
20+
38
21+
7
22+
42
23+
25
24+
9
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
65
2+
48
3+
10
4+
47
5+
47
6+
13
7+
14
8+
35
9+
20
10+
19
11+
15
12+
17
13+
49
14+
28
15+
46
16+
50
17+
23
18+
14
19+
47
20+
25
21+
18
22+
39
23+
27
24+
48
25+
50
26+
13
27+
48
28+
12
29+
27
30+
42
31+
34
32+
19
33+
47
34+
22
35+
27
36+
50
37+
22
38+
42
39+
38
40+
23
41+
19
42+
43
43+
20
44+
23
45+
10
46+
31
47+
41
48+
27
49+
40
50+
24
51+
21
52+
11
53+
29
54+
13
55+
35
56+
46
57+
40
58+
50
59+
10
60+
16
61+
29
62+
44
63+
37
64+
41
65+
45
66+
44

0 commit comments

Comments
 (0)