Skip to content

Commit 59c2964

Browse files
committed
Adding tests for "Let's go to the cinema!".
1 parent 117f756 commit 59c2964

13 files changed

+432
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Tests for "IP mask calculating".
2626
- Tests for "Domino puzzle".
2727
- Tests for "Goldbach’s conjecture".
28+
- Tests for "Let's go to the cinema!".
2829

2930
## [1.16.0] - 2022-12-31
3031
### Added
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* The "Let's go to the cinema!" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/lets-go-to-the-cinema}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const maxRow = parseInt(inputs[0]);
8+
const maxColumn = parseInt(inputs[1]);
9+
const n = parseInt(readline());
10+
for (let i = 0; i < n; i++) {
11+
var inputs = readline().split(' ');
12+
const numPersons = parseInt(inputs[0]);
13+
const row = parseInt(inputs[1]);
14+
const column = parseInt(inputs[2]);
15+
}
16+
17+
// Write an answer using console.log()
18+
// To debug: console.error('Debug messages...');
19+
20+
console.log('0 0');
21+
}
22+
23+
export { execute };
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/letsGoToTheCinema/letsGoToTheCinema.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Let's go to the cinema!", 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("Example", function() {
21+
let inputFile = new File(__dirname + 'input/01 - example.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"2 5"
28+
);
29+
});
30+
31+
test("Family comes to living room to watch TV", function() {
32+
let inputFile = new File(__dirname + 'input/02 - family comes to living room to watch tv.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"1 4"
39+
);
40+
});
41+
42+
test("Family TV, but cat is sitting on edge of sofa", function() {
43+
let inputFile = new File(__dirname + 'input/03 - family TV, but cat is sitting on edge of sofa.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"1 4"
50+
);
51+
});
52+
53+
test("Family TV, but 2 cats are sitting on middle of sofa", function() {
54+
let inputFile = new File(__dirname + 'input/04 - family TV, but 2 cats are sitting on middle of sofa.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"2 4"
61+
);
62+
});
63+
64+
test("There ain't no problem!", function() {
65+
let inputFile = new File(__dirname + 'input/05 - there ain\'t no problem!.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"7 18"
72+
);
73+
});
74+
75+
test("We ain't need no seat numbering!", function() {
76+
let inputFile = new File(__dirname + 'input/06 - we ain\'t need no seat numbering!.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"1 2"
83+
);
84+
});
85+
86+
test("Small cinema", function() {
87+
let inputFile = new File(__dirname + 'input/07 - small cinema.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"9 75"
94+
);
95+
});
96+
97+
test("Bigger cinema", function() {
98+
let inputFile = new File(__dirname + 'input/08 - bigger cinema.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"66 2043"
105+
);
106+
});
107+
108+
test("Chain reaction", function() {
109+
let inputFile = new File(__dirname + 'input/09 - chain reaction.txt');
110+
111+
execute(inputFile.readline.bind(inputFile));
112+
113+
assert.strictEqual(
114+
console.log.getCall(0).args[0],
115+
"1 1"
116+
);
117+
});
118+
119+
test("Blind date", function() {
120+
let inputFile = new File(__dirname + 'input/10 - blind date.txt');
121+
122+
execute(inputFile.readline.bind(inputFile));
123+
124+
assert.strictEqual(
125+
console.log.getCall(0).args[0],
126+
"8 12"
127+
);
128+
});
129+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2 4
2+
4
3+
2 1 2
4+
2 1 1
5+
2 0 1
6+
2 1 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1 4
2+
1
3+
4 0 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1 5
2+
2
3+
1 0 0
4+
4 0 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1 6
2+
3
3+
1 0 2
4+
1 0 4
5+
4 0 1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
3 6
2+
7
3+
2 2 4
4+
1 0 5
5+
2 2 2
6+
2 2 0
7+
6 1 0
8+
3 0 0
9+
2 0 3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
3 6
2+
7
3+
1 0 0
4+
2 0 0
5+
2 0 0
6+
2 0 0
7+
6 0 0
8+
3 0 0
9+
2 0 0
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
19 10
2+
33
3+
7 6 1
4+
9 12 1
5+
2 12 3
6+
9 11 1
7+
9 4 0
8+
5 0 0
9+
5 6 5
10+
8 4 1
11+
9 8 1
12+
8 14 0
13+
3 10 4
14+
7 11 2
15+
2 15 4
16+
3 12 2
17+
1 10 3
18+
2 13 6
19+
4 12 4
20+
9 1 0
21+
8 10 0
22+
9 16 1
23+
3 5 7
24+
4 14 4
25+
10 15 0
26+
4 12 1
27+
1 6 3
28+
7 14 2
29+
7 3 1
30+
2 18 6
31+
10 0 0
32+
8 15 1
33+
5 10 4
34+
8 12 1
35+
2 3 3

0 commit comments

Comments
 (0)