Skip to content

Commit 5537e74

Browse files
committed
Adding tests for "Fair numbering".
1 parent 5d7b9ad commit 5537e74

17 files changed

+1275
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Tests for "Crossword".
3434
- Tests for "Futoshiki solver".
3535
- Tests for "Frog exchange".
36+
- Tests for "Fair numbering".
3637

3738
## [1.11.0] - 2022-07-31
3839
### Added
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* The "Fair numbering" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/fair-numbering}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
var inputs = readline().split(' ');
9+
const st = parseInt(inputs[0]);
10+
const ed = parseInt(inputs[1]);
11+
}
12+
for (let i = 0; i < N; i++) {
13+
14+
// Write an answer using console.log()
15+
// To debug: console.error('Debug messages...');
16+
17+
console.log('answer');
18+
}
19+
}
20+
21+
export { execute };
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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/fairNumbering/fairNumbering.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Fair numbering", 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("Examples", function() {
22+
let inputFile = new File(__dirname + 'input/01 - examples.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - examples.txt');
27+
});
28+
29+
test("Typical cases", function() {
30+
let inputFile = new File(__dirname + 'input/02 - typical cases.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - typical cases.txt');
35+
});
36+
37+
test("Wide range", function() {
38+
let inputFile = new File(__dirname + 'input/03 - wide range.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - wide range.txt');
43+
});
44+
45+
test("Bigger numbers", function() {
46+
let inputFile = new File(__dirname + 'input/04 - bigger numbers.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - bigger numbers.txt');
51+
});
52+
53+
test("Stress test 1", function() {
54+
let inputFile = new File(__dirname + 'input/05 - stress test 1.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - stress test 1.txt');
59+
});
60+
61+
test("Stress test 2", function() {
62+
let inputFile = new File(__dirname + 'input/06 - stress test 2.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - stress test 2.txt');
67+
});
68+
69+
test("Stress test 3", function() {
70+
let inputFile = new File(__dirname + 'input/07 - stress test 3.txt');
71+
72+
execute(inputFile.readline.bind(inputFile));
73+
74+
assertOutputAnswer(__dirname + 'output/07 - stress test 3.txt');
75+
});
76+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
1 200
3+
8 10
4+
9 10
5+
8 11
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
21
2+
4 10
3+
4 11
4+
4 12
5+
4 13
6+
4 14
7+
3 15
8+
3 16
9+
3 17
10+
2 10
11+
99 100
12+
98 100
13+
97 101
14+
1 1002
15+
9 1002
16+
10 1002
17+
4 1000000
18+
5 1000000
19+
6 1000000
20+
9 1000000
21+
10 1000000
22+
11 1000000
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
100
2+
42 145650
3+
5 216183
4+
16 343151
5+
93 871559
6+
28 319457
7+
1 571984
8+
74 502960
9+
8 611597
10+
38 743651
11+
98 978812
12+
73 268847
13+
60 424642
14+
44 581041
15+
40 787051
16+
65 348855
17+
97 617744
18+
32 845561
19+
24 725969
20+
76 329829
21+
77 943618
22+
16 308888
23+
93 653731
24+
5 811752
25+
24 605254
26+
36 787166
27+
86 436309
28+
12 144065
29+
71 627116
30+
70 952205
31+
81 519778
32+
63 806211
33+
59 663973
34+
36 840602
35+
32 837379
36+
68 78803
37+
36 918789
38+
38 55466
39+
43 295094
40+
29 972392
41+
52 355841
42+
35 378966
43+
54 991992
44+
58 653644
45+
43 889777
46+
78 3815
47+
21 246347
48+
88 303640
49+
71 287374
50+
59 89049
51+
48 337904
52+
89 480763
53+
67 645812
54+
61 660636
55+
31 914478
56+
56 882036
57+
25 72161
58+
66 945230
59+
60 417545
60+
68 516435
61+
69 118772
62+
28 634433
63+
61 114698
64+
5 931515
65+
81 948462
66+
72 247931
67+
53 6077
68+
99 243107
69+
57 459572
70+
58 743472
71+
92 358958
72+
89 497999
73+
86 423754
74+
98 992202
75+
93 263531
76+
64 69083
77+
64 937817
78+
31 549601
79+
69 598532
80+
66 675248
81+
33 410985
82+
47 95299
83+
79 910158
84+
55 659725
85+
33 503143
86+
92 787884
87+
75 917595
88+
35 944063
89+
2 708576
90+
66 229006
91+
16 210818
92+
83 588776
93+
96 73731
94+
23 527306
95+
20 39261
96+
19 30651
97+
35 579811
98+
29 370805
99+
37 443974
100+
99 340413
101+
5 579570
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
100
2+
94697 2017500
3+
68968 2032495
4+
50182 2077351
5+
3934 1003903
6+
18541 4053523
7+
82132 1084309
8+
85359 1000727
9+
21892 3045536
10+
77566 1097496
11+
32804 93666
12+
84414 2036471
13+
10054 1005996
14+
61524 3016268
15+
67760 3012932
16+
7145 13262
17+
54862 4031061
18+
24984 3001338
19+
74523 2060932
20+
47747 3075505
21+
24201 82173
22+
23681 2034251
23+
92432 4033151
24+
68027 2086478
25+
16070 3083358
26+
37170 4035018
27+
47465 4039874
28+
26891 2089045
29+
93573 1038790
30+
8481 3017027
31+
98746 3053786
32+
86213 89186
33+
73876 89347
34+
26654 3002120
35+
54337 57425
36+
48828 1085388
37+
55943 4068746
38+
68966 1012491
39+
13860 63671
40+
55147 2082998
41+
66723 3037473
42+
93446 1047741
43+
13981 1040032
44+
95117 4012404
45+
43556 2083628
46+
34187 1020830
47+
13305 4030424
48+
34254 4001044
49+
14036 1087116
50+
24707 35487
51+
88621 2013363
52+
66784 2000759
53+
37256 50533
54+
69374 1084058
55+
76885 1041846
56+
30134 3008361
57+
94702 3005064
58+
32719 3066116
59+
94669 2079166
60+
42379 4046973
61+
32229 84263
62+
82270 2014893
63+
4026 4023211
64+
37006 1079373
65+
44431 4065507
66+
94909 4024040
67+
61175 4029795
68+
48470 1053649
69+
58911 85860
70+
46563 2072875
71+
29383 84805
72+
15099 51370
73+
20470 2025236
74+
27822 2044796
75+
5764 2036047
76+
56828 3065609
77+
24311 4027630
78+
39345 75099
79+
86067 1048572
80+
52430 83734
81+
23733 2090443
82+
91627 3006142
83+
39427 4047733
84+
71524 2020555
85+
87322 2029661
86+
58975 2049791
87+
66454 3023323
88+
38328 1093621
89+
80344 2038800
90+
47857 1008227
91+
67628 3064191
92+
61523 2037347
93+
48939 4089720
94+
59756 3021038
95+
37239 1078031
96+
75197 1054507
97+
5961 2020703
98+
86963 1033679
99+
30629 1048059
100+
17216 4080716
101+
94675 4075607

0 commit comments

Comments
 (0)