Skip to content

Commit 4e53726

Browse files
committed
Adding tests for "Add'em up".
1 parent fd6e27d commit 4e53726

File tree

10 files changed

+128
-0
lines changed

10 files changed

+128
-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 "Murder in the village!".
2929
- Tests for "Dead men's shot".
3030
- Tests for "Darts".
31+
- Tests for "Add'em up".
3132

3233
## [1.7.0] - 2022-03-31
3334
### Added
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "Add'em up" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
var inputs = readline().split(' ');
7+
for (let i = 0; i < N; i++) {
8+
const x = parseInt(inputs[i]);
9+
}
10+
11+
// Write an answer using console.log()
12+
// To debug: console.error('Debug messages...');
13+
14+
console.log('0');
15+
}
16+
17+
export { execute };
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/addEmUp/addEmUp.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Add'em up", 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+
9
28+
);
29+
});
30+
31+
test("Easy", function() {
32+
let inputFile = new File(__dirname + 'input/02 - easy.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
24
39+
);
40+
});
41+
42+
test("In a row", function() {
43+
let inputFile = new File(__dirname + 'input/03 - in a row.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
261
50+
);
51+
});
52+
53+
test("XX", function() {
54+
let inputFile = new File(__dirname + 'input/04 - XX.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
4502962
61+
);
62+
});
63+
64+
test("CC", function() {
65+
let inputFile = new File(__dirname + 'input/05 - CC.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
7718767
72+
);
73+
});
74+
75+
test("D", function() {
76+
let inputFile = new File(__dirname + 'input/06 - D.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
224281401
83+
);
84+
});
85+
86+
test("M", function() {
87+
let inputFile = new File(__dirname + 'input/07 - M.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
504259
94+
);
95+
});
96+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1 2 3
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
1 4 3 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
9
2+
9 9 9 9 9 9 9 9 9
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
20
2+
15282 6674 93033 48628 75335 61596 66495 33570 15004 60598 91072 79972 78971 72325 15986 95574 41770 39882 96387 9413
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
200
2+
8414 8849 5979 4328 1860 1929 8038 6898 4604 4280 6505 9610 5759 5778 3866 2291 559 757 7576 9449 9567 3887 7975 1587 9969 7756 680 341 8989 9932 4085 4513 9963 4867 9622 5629 2206 731 4483 7776 8013 1988 582 693 4591 5195 2619 1234 1347 8472 7976 3 1689 209 9619 8703 5792 8876 8148 8029 9020 834 649 2463 403 1535 1088 9195 3477 8118 8772 4459 7894 274 5222 6347 3098 8999 5895 1232 8059 7030 8912 4599 7978 4671 607 9035 8240 9921 5630 560 5567 5005 1953 3501 6138 2585 1996 5271 6493 5824 991 7111 7498 902 287 3966 4242 969 8322 8335 9501 5124 8918 9162 102 5949 4686 3097 6357 222 8458 8484 2170 6769 9010 1999 4179 1652 8032 4755 6970 9404 5255 713 2862 309 4643 8018 7933 8247 3358 1477 395 8997 7420 8080 1809 399 4213 8543 8452 8728 2124 7275 7441 7666 7936 8985 4515 6420 8814 3875 8448 7469 9105 1412 38 819 7304 7261 61 148 9458 1413 3241 2078 9448 4717 9311 3882 422 8609 4689 5538 3240 6234 1896 8099 8462 7952 9677 9198 7547 5997 7284 4137 7344 2397
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
500
2+
94583 68587 88721 95522 48527 8260 38227 72607 78708 72731 89285 68112 16119 54571 60361 88562 26363 59919 95673 98549 2030 93431 93046 27396 67971 29368 55340 57698 60110 52926 77411 96880 17787 89629 48197 88491 73867 20261 41319 57746 2635 40500 19510 44197 58931 29285 63967 40744 84376 54022 90362 17959 13295 71399 85940 50900 27775 57646 17368 50125 56321 12872 60602 51672 71287 42490 73600 47984 52614 93173 53548 95641 80721 60840 4266 25102 85779 79120 86739 14813 18713 7690 30748 78824 75738 46376 40030 68044 66483 16162 99298 18270 76355 28708 2953 20177 65280 81510 77877 60724 16885 6201 16152 11065 33305 28348 64663 32977 89356 35534 21658 86034 15248 42111 16947 84986 37794 95967 3752 98701 71572 68824 66975 24731 26760 45335 52005 97021 64363 91236 4634 4637 65707 17108 13277 30037 71734 97716 97744 30928 23057 66918 30695 32077 17426 70664 45619 33827 603 36463 23845 41726 51572 25939 25057 82342 83011 75780 66369 32000 1546 6234 77858 73646 59133 40842 87504 64402 1342 70164 11849 81425 69815 28345 67184 94610 95219 28138 42416 88037 29466 5116 17162 73536 62504 59672 67454 19109 47976 23279 61330 67135 75666 85162 81794 15531 89726 9279 12516 76244 64963 71487 87638 71447 12753 40493 1799 31045 60839 8777 3038 84198 28050 30922 56075 84890 45763 78251 44456 64442 81228 56252 74252 32894 1047 82841 87628 10200 55010 84727 32046 71518 34234 43419 92139 46213 36915 77893 6560 21512 47874 5929 13650 67144 37304 30078 36347 97646 33755 4527 35573 35019 13986 28944 93506 74336 38668 91051 28566 83034 7294 91031 37730 40821 8728 59306 91421 27905 16466 75653 22320 49634 88120 76878 10719 97617 29823 37115 74959 15936 1571 64234 59193 5467 55039 87661 41801 50890 97831 95555 70771 5811 6341 61954 45939 9244 79215 22288 96159 12142 16609 56210 619 89461 82653 40091 20216 34755 28923 28005 43227 26517 71950 11294 84166 95022 45813 26458 88437 82399 19323 1862 99991 65416 80236 43645 78934 37143 660 69555 54885 29327 95445 60078 98213 15269 88836 83189 54483 91876 74113 64481 26098 19056 46162 81072 45521 10087 24667 57336 34201 87044 61787 42616 85814 22013 72742 79786 81471 46348 27451 24501 32963 83754 89729 80288 27729 84823 52515 88864 2916 99799 11269 61138 51337 68182 73697 27844 82223 48044 5731 80845 6954 16476 20541 55613 30788 33110 84391 65295 39841 26204 25655 24156 35469 94050 84218 84457 93700 27246 70604 65856 65853 10751 60025 73756 30420 86411 31536 24797 91635 40608 85217 58620 29852 29996 82291 90617 44341 87223 65476 53776 36369 3438 80222 43561 54167 25851 28434 40559 35665 57199 33460 52600 82291 60770 58707 46883 32838 91666 40339 33793 89680 96807 78633 13353 85794 84183 10418 90575 3454 81413 84529 13391 6338 40899 30147 60835 38261 42169 89856 77493 23949 8126 32240 91342 80667 19843 86471 78860 90356 60143 41151 50226 56892 12549 67216 67193 68977 10626 37231 81508 38130 12194 50592 87442 81322 47298 82233 53773 71004 13280 19925 85823 95212 8158 42258 40324 10888 20678
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1000
2+
71 76 72 45 89 36 2 55 27 83 55 38 55 35 15 90 62 70 89 75 76 84 9 44 97 98 50 34 49 63 18 6 97 96 98 85 17 68 19 90 54 44 86 10 97 25 64 81 53 75 61 56 47 70 44 8 63 92 40 98 29 58 80 47 42 4 40 61 23 12 81 80 2 89 16 46 31 29 9 28 28 63 55 35 64 19 14 66 69 19 9 61 85 59 55 90 95 40 84 41 11 72 39 99 41 85 27 71 44 85 71 82 45 41 36 22 28 64 55 61 83 8 81 41 69 2 66 76 97 70 37 77 60 36 6 21 79 49 65 20 50 92 49 21 57 10 42 69 34 4 13 25 20 83 78 13 88 97 26 97 6 4 85 88 33 98 93 89 71 16 31 73 60 13 53 19 90 61 4 96 80 76 43 25 2 2 3 16 49 93 70 36 87 9 46 60 76 36 92 33 62 10 61 36 78 24 94 94 75 45 22 8 71 26 79 78 11 15 44 44 19 42 23 35 29 42 53 2 77 59 77 27 73 77 95 85 85 5 19 32 45 85 17 93 55 5 1 90 27 75 46 73 48 40 31 99 37 84 46 26 1 14 39 21 12 36 58 91 16 84 4 67 83 58 60 34 82 82 50 81 45 59 1 93 43 87 42 11 69 85 98 78 99 95 43 1 36 61 97 82 39 20 6 74 39 18 28 73 87 89 71 14 92 39 85 45 76 23 52 76 57 10 15 4 87 79 27 10 27 90 47 86 37 19 56 99 9 99 86 88 2 52 81 39 11 62 51 87 54 74 78 1 55 89 20 42 99 74 10 15 26 94 57 44 83 22 27 95 61 52 74 52 64 96 47 13 43 6 37 58 19 68 21 91 90 96 75 75 21 82 57 34 79 31 33 56 6 8 29 12 33 55 8 83 88 11 46 42 83 98 44 70 18 77 46 71 21 5 91 99 72 10 40 6 44 84 51 29 60 67 77 74 92 71 16 77 22 83 79 7 39 50 36 4 7 31 61 48 11 66 1 45 93 58 52 5 98 83 74 54 99 96 17 39 43 67 68 25 46 13 98 12 56 38 83 15 95 30 84 65 20 6 82 34 83 61 44 26 24 3 59 73 44 55 76 13 5 89 38 33 99 83 74 10 39 1 62 67 63 64 47 24 81 2 73 70 17 37 86 4 94 50 57 86 31 55 12 54 52 98 69 21 5 11 76 41 52 82 65 61 93 4 75 7 16 84 30 68 32 53 65 79 7 24 91 44 87 6 68 61 95 50 76 8 49 59 17 75 11 91 97 90 85 16 77 18 44 52 74 31 92 15 94 43 52 72 47 89 82 96 23 16 57 53 37 89 49 26 62 45 55 24 70 7 84 38 48 86 3 70 80 54 22 73 84 94 24 10 31 61 77 16 69 16 72 64 20 7 84 93 54 86 6 67 66 92 83 79 66 45 84 1 53 67 18 55 2 78 53 45 49 71 98 37 53 83 64 49 28 90 1 64 77 79 12 93 25 61 57 8 3 84 76 19 56 30 18 99 94 57 80 52 47 39 65 32 73 47 91 5 43 16 87 40 28 94 75 30 90 48 56 6 23 93 21 59 15 47 68 43 23 49 66 76 64 88 52 23 24 88 33 31 3 20 42 2 48 21 73 13 82 40 34 68 5 45 70 40 83 29 32 83 20 92 40 58 60 10 35 5 1 87 53 58 94 23 64 25 46 21 46 33 22 98 38 47 54 13 63 27 78 95 2 5 4 91 72 7 53 81 26 82 50 26 12 45 41 41 94 98 2 70 93 37 80 6 31 27 20 94 18 76 76 13 61 89 81 85 97 87 39 69 30 74 90 72 38 10 44 74 41 83 30 93 33 46 2 25 78 65 28 74 11 2 79 71 33 67 18 93 54 63 89 59 69 53 62 36 80 51 98 86 58 67 38 25 68 21 28 66 62 61 2 15 92 40 56 95 86 78 11 78 78 39 72 91 29 18 57 16 88 89 69 85 28 66 72 35 14 41 93 74 73 85 91 60 97 32 27 2 40 58 6 97 20 75 29 27 92 40 81 1 78 1 33 79 79 7 18 97 33 44 57 21 10 18 23 78 73 97 41 82 11 38 30 78 98 93 68 87 63 26 87 58 53 70 91 22 19 82 92 16 44 50 53 21 60 92 25 19 10 28 99 44 46 75 68 57 93 43 46 73 10 39 45 9 66 44 56 44 86 64 24 83 11 87 19 52 21 18 74 8 80 87 57 67 45 78 57 58

0 commit comments

Comments
 (0)