Skip to content

Commit ea88e4e

Browse files
committed
Adding tests for "Morellet’s random lines".
1 parent d94a633 commit ea88e4e

File tree

11 files changed

+367
-0
lines changed

11 files changed

+367
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Tests for "Auto pickup".
2929
- Tests for "Annihilation".
3030
- Tests for "Faro shuffle".
31+
- Tests for "Morellet’s random lines".
3132

3233
## [1.9.0] - 2022-06-01
3334
### Added
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* The "Morellet’s random lines" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/morellets-random-lines}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const xA = parseInt(inputs[0]);
8+
const yA = parseInt(inputs[1]);
9+
const xB = parseInt(inputs[2]);
10+
const yB = parseInt(inputs[3]);
11+
const n = parseInt(readline());
12+
for (let i = 0; i < n; i++) {
13+
var inputs = readline().split(' ');
14+
const a = parseInt(inputs[0]);
15+
const b = parseInt(inputs[1]);
16+
const c = parseInt(inputs[2]);
17+
}
18+
19+
// Write an answer using console.log()
20+
// To debug: console.error('Debug messages...');
21+
22+
console.log('YES|NO|ON A LINE');
23+
}
24+
25+
export { execute };
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/morelletsRandomLines/morelletsRandomLines.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Morellet’s random lines", 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("One line", function() {
21+
let inputFile = new File(__dirname + 'input/01 - one line.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"YES"
28+
);
29+
});
30+
31+
test("Two lines", function() {
32+
let inputFile = new File(__dirname + 'input/02 - two lines.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"YES"
39+
);
40+
});
41+
42+
test("On a line", function() {
43+
let inputFile = new File(__dirname + 'input/03 - on a line.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"ON A LINE"
50+
);
51+
});
52+
53+
test("Many lines", function() {
54+
let inputFile = new File(__dirname + 'input/04 - many lines.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"NO"
61+
);
62+
});
63+
64+
test("Same line", function() {
65+
let inputFile = new File(__dirname + 'input/05 - same line.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"YES"
72+
);
73+
});
74+
75+
test("Lots of lines", function() {
76+
let inputFile = new File(__dirname + 'input/06 - lots of lines.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"ON A LINE"
83+
);
84+
});
85+
86+
test("Lots of lines 2", function() {
87+
let inputFile = new File(__dirname + 'input/07 - lots of lines 2.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"NO"
94+
);
95+
});
96+
97+
test("Mind the sign", function() {
98+
let inputFile = new File(__dirname + 'input/08 - mind the sign.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"NO"
105+
);
106+
});
107+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1 1 0 0
2+
1
3+
1 2 3
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3 2 -2 -2
2+
2
3+
1 2 3
4+
1 1 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-1 0 -2 0
2+
1
3+
1 1 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-5 3 4 2
2+
10
3+
-7 6 -9
4+
-6 10 -7
5+
-3 -4 -2
6+
-3 1 0
7+
-3 8 3
8+
1 -5 -4
9+
3 -8 10
10+
3 9 -5
11+
8 3 -2
12+
10 4 -3
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3 2 -3 1
2+
2
3+
1 2 3
4+
2 4 6
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
7 -7 5 -5
2+
100
3+
-3 5 3
4+
9 -2 10
5+
-8 -5 3
6+
7 10 -5
7+
2 -4 1
8+
-6 9 5
9+
-3 6 9
10+
2 -6 -6
11+
-4 -2 -5
12+
0 1 3
13+
5 7 10
14+
8 2 -6
15+
3 4 1
16+
-10 5 -2
17+
1 6 -9
18+
3 0 3
19+
-6 -6 -1
20+
8 7 6
21+
-9 -9 9
22+
-7 7 -6
23+
9 -10 5
24+
0 5 2
25+
-4 -1 7
26+
2 2 -5
27+
-6 -4 4
28+
0 9 -7
29+
2 -7 10
30+
10 -6 -8
31+
-5 -9 4
32+
7 -6 0
33+
-5 -2 5
34+
-4 -9 -9
35+
4 -10 1
36+
7 7 10
37+
7 -6 1
38+
1 4 2
39+
-9 -4 3
40+
-1 0 -1
41+
-5 6 -10
42+
-10 -2 6
43+
-3 10 9
44+
6 5 5
45+
-2 -7 -4
46+
-6 3 1
47+
9 -3 1
48+
8 -6 2
49+
10 -8 5
50+
7 6 5
51+
-10 -2 -8
52+
9 -7 -7
53+
7 -1 -6
54+
9 10 -2
55+
-1 6 -6
56+
-5 -10 -10
57+
0 3 -7
58+
-9 8 -9
59+
7 -8 -4
60+
-7 5 -3
61+
9 -2 10
62+
-10 -9 2
63+
4 -3 -7
64+
2 10 8
65+
9 5 4
66+
9 0 9
67+
-10 10 0
68+
8 8 10
69+
0 -5 -1
70+
5 -1 2
71+
5 3 1
72+
3 10 8
73+
10 6 -4
74+
8 -9 0
75+
6 2 5
76+
9 4 6
77+
-8 7 -8
78+
5 -3 -3
79+
-1 -6 -9
80+
-9 -1 5
81+
-1 -3 -8
82+
-4 -8 -2
83+
5 8 10
84+
5 10 -9
85+
10 4 -9
86+
-7 -7 -2
87+
7 7 -4
88+
10 7 7
89+
7 4 -1
90+
-9 7 5
91+
8 0 -4
92+
0 -10 3
93+
7 6 4
94+
2 8 -9
95+
-5 3 -3
96+
10 -4 -1
97+
1 10 -4
98+
-8 -9 7
99+
5 -8 -7
100+
-8 4 -2
101+
-5 0 5
102+
7 -3 -4
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
-10 201 102 86
2+
100
3+
-3 5 3
4+
9 -2 10
5+
-8 -5 3
6+
7 10 -5
7+
2 -4 1
8+
-6 9 5
9+
-3 6 9
10+
2 -6 -6
11+
-4 -2 -5
12+
0 1 3
13+
5 7 10
14+
8 2 -6
15+
3 4 1
16+
-10 5 -2
17+
1 6 -9
18+
3 0 3
19+
-6 -6 -1
20+
8 7 6
21+
-9 -9 9
22+
-7 7 -6
23+
9 -10 5
24+
0 5 2
25+
-4 -1 7
26+
2 2 -5
27+
-6 -4 4
28+
0 9 -7
29+
2 -7 10
30+
10 -6 -8
31+
-5 -9 4
32+
7 -6 0
33+
-5 -2 5
34+
-4 -9 -9
35+
4 -10 1
36+
7 7 10
37+
7 -6 1
38+
1 4 2
39+
-9 -4 3
40+
-1 0 -1
41+
-5 6 -10
42+
-10 -2 6
43+
-3 10 9
44+
6 5 5
45+
-2 -7 -4
46+
-6 3 1
47+
9 -3 1
48+
8 -6 2
49+
10 -8 5
50+
7 6 5
51+
-10 -2 -8
52+
9 -7 -7
53+
7 -1 -6
54+
9 10 -2
55+
-1 6 -6
56+
-5 -10 -10
57+
0 3 -7
58+
-9 8 -9
59+
7 -8 -4
60+
-7 5 -3
61+
9 -2 10
62+
-10 -9 2
63+
4 -3 -7
64+
2 10 8
65+
9 5 4
66+
9 0 9
67+
-10 10 0
68+
8 8 10
69+
0 -5 -1
70+
5 -1 2
71+
5 3 1
72+
3 10 8
73+
10 6 -4
74+
8 -9 0
75+
6 2 5
76+
9 4 6
77+
-8 7 -8
78+
5 -3 -3
79+
-1 -6 -9
80+
-9 -1 5
81+
-1 -3 -8
82+
-4 -8 -2
83+
5 8 10
84+
5 10 -9
85+
10 4 -9
86+
-7 -7 -2
87+
7 7 -4
88+
10 7 7
89+
7 4 -1
90+
-9 7 5
91+
8 0 -4
92+
0 -10 3
93+
7 6 4
94+
2 8 -9
95+
-5 3 -3
96+
10 -4 -1
97+
1 10 -4
98+
-8 -9 7
99+
5 -8 -7
100+
-8 4 -2
101+
-5 0 5
102+
7 -3 -4

0 commit comments

Comments
 (0)