Skip to content

Commit 519d55e

Browse files
committed
Adding tests for "All operations are equal!".
1 parent 7c8782e commit 519d55e

File tree

13 files changed

+713
-0
lines changed

13 files changed

+713
-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 "Anagrams".
2929
- Tests for "The stonemason".
3030
- Tests for "Continued fractions".
31+
- Tests for "All operations are equal!".
3132

3233
## [1.14.0] - 2022-10-31
3334
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "All operations are equal!" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/all-operations-are-equal}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
const X = parseInt(readline());
9+
}
10+
for (let i = 0; i < N; i++) {
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
}
18+
19+
export { execute };
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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/allOperationsAreEqual/allOperationsAreEqual.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("All operations are equal!", 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("Test 1", function() {
22+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - test 1.txt');
27+
});
28+
29+
test("Test 2", function() {
30+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - test 2.txt');
35+
});
36+
37+
test("Test 3", function() {
38+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - test 3.txt');
43+
});
44+
45+
test("Test 4", function() {
46+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - test 4.txt');
51+
});
52+
53+
test("Test 5", function() {
54+
let inputFile = new File(__dirname + 'input/05 - test 5.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - test 5.txt');
59+
});
60+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
8
3+
1
4+
69
5+
128
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
1
3+
2
4+
3
5+
4
6+
5
7+
99996
8+
99997
9+
99998
10+
99999
11+
100000
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
100
2+
85788
3+
98262
4+
68384
5+
17148
6+
23863
7+
14751
8+
19160
9+
72496
10+
72376
11+
3596
12+
9848
13+
81520
14+
64493
15+
39575
16+
56493
17+
63940
18+
42072
19+
84699
20+
14844
21+
47380
22+
25443
23+
19756
24+
66650
25+
1784
26+
21866
27+
5444
28+
89649
29+
27346
30+
45855
31+
50196
32+
5720
33+
59224
34+
84856
35+
85707
36+
26268
37+
77060
38+
65876
39+
70906
40+
13867
41+
39088
42+
71046
43+
98960
44+
25431
45+
20872
46+
78476
47+
23130
48+
80444
49+
16473
50+
32798
51+
7068
52+
30870
53+
64892
54+
87171
55+
78968
56+
71496
57+
76887
58+
49518
59+
10350
60+
85652
61+
4952
62+
22488
63+
57477
64+
24606
65+
4316
66+
67992
67+
5720
68+
56756
69+
36368
70+
88985
71+
26001
72+
83124
73+
11322
74+
17689
75+
54567
76+
4692
77+
45315
78+
62444
79+
8712
80+
64268
81+
40796
82+
46813
83+
65664
84+
58636
85+
64071
86+
98150
87+
46804
88+
82024
89+
30676
90+
67648
91+
26624
92+
97220
93+
59166
94+
1084
95+
36244
96+
30060
97+
35271
98+
59968
99+
22508
100+
57379
101+
90852
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
100
2+
71470
3+
83935
4+
541
5+
17381
6+
95226
7+
18619
8+
80911
9+
63227
10+
56986
11+
18641
12+
42565
13+
50273
14+
86541
15+
25162
16+
46702
17+
26977
18+
15411
19+
61946
20+
27043
21+
17705
22+
83579
23+
23023
24+
92147
25+
67997
26+
47171
27+
74182
28+
95259
29+
53385
30+
84247
31+
63499
32+
1529
33+
21410
34+
2503
35+
66505
36+
85461
37+
25162
38+
4933
39+
82695
40+
63471
41+
66322
42+
82442
43+
25103
44+
36861
45+
58890
46+
14263
47+
5495
48+
87259
49+
42761
50+
41470
51+
72794
52+
78817
53+
51937
54+
16418
55+
64410
56+
38581
57+
74247
58+
94377
59+
39011
60+
74201
61+
50057
62+
82477
63+
55311
64+
83606
65+
61177
66+
85218
67+
79597
68+
71569
69+
62167
70+
67182
71+
12683
72+
60555
73+
42653
74+
47978
75+
83281
76+
20707
77+
97474
78+
60142
79+
8458
80+
90349
81+
6198
82+
59021
83+
93398
84+
48014
85+
11802
86+
72003
87+
73217
88+
85067
89+
3857
90+
68677
91+
45910
92+
17059
93+
71922
94+
23983
95+
41995
96+
17279
97+
73545
98+
72769
99+
26593
100+
68206
101+
58002

0 commit comments

Comments
 (0)