Skip to content

Commit 8a5539a

Browse files
committed
Adding tests for "Find the missing plus
signs in addition".
1 parent 0449271 commit 8a5539a

File tree

9 files changed

+106
-0
lines changed

9 files changed

+106
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- Tests for "3×N tiling".
2828
- Tests for "Hexagonal maze - part2".
2929
- Tests for "Byte pair encoding".
30+
- Tests for "Find the missing plus signs in addition".
3031

3132
## [1.13.0] - 2022-09-30
3233
### Added
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* The "Find the missing plus signs in addition" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/find-the-missing-plus-signs-in-addition}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
const S = parseInt(readline());
8+
const O = readline();
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('No solution or recovered addition(s)');
14+
}
15+
16+
export { execute };
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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/findTheMissingPlusSignsInAddition/findTheMissingPlusSignsInAddition.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Find the missing plus signs in addition", 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("Example with unique solution", function() {
22+
let inputFile = new File(__dirname + 'input/01 - example with unique solution.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
"44+133=177"
29+
);
30+
});
31+
32+
test("No solution there", function() {
33+
let inputFile = new File(__dirname + 'input/02 - no solution there.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
"No solution"
40+
);
41+
});
42+
43+
test("More than one solution", function() {
44+
let inputFile = new File(__dirname + 'input/03 - more than one solution.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assertOutputAnswer(__dirname + 'output/03 - more than one solution.txt');
49+
});
50+
51+
test("Ten terms", function() {
52+
let inputFile = new File(__dirname + 'input/04 - ten terms.txt');
53+
54+
execute(inputFile.readline.bind(inputFile));
55+
56+
assert.strictEqual(
57+
console.log.getCall(0).args[0],
58+
"48+113+19+189+25+37+72+81+212+17=813"
59+
);
60+
});
61+
62+
test("59 digits in O", function() {
63+
let inputFile = new File(__dirname + 'input/05 - 59 digits in O.txt');
64+
65+
execute(inputFile.readline.bind(inputFile));
66+
67+
assert.strictEqual(
68+
console.log.getCall(0).args[0],
69+
"964510623+54170+987541234+7772451+246+94514215+159874623+432158796=2646426358"
70+
);
71+
});
72+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
177
3+
44133
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
35
3+
1313
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
6
2+
678
3+
24261236141232
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10
2+
813
3+
48113191892537728121217
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
8
2+
2646426358
3+
96451062354170987541234777245124694514215159874623432158796
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
24+26+123+61+412+32=678
2+
242+61+236+14+123+2=678

0 commit comments

Comments
 (0)