Skip to content

Commit b6e90b2

Browse files
committed
Adding tests for "Solid integer".
1 parent 5499c52 commit b6e90b2

File tree

12 files changed

+143
-0
lines changed

12 files changed

+143
-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 "Palindromic decomposition".
2929
- Tests for "Battleship".
3030
- Tests for "Texas holdem".
31+
- Tests for "Solid integer".
3132

3233
## [1.15.0] - 2022-11-30
3334
### Added
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* The "Solid integer" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/solid-integer}
4+
*/
5+
function execute(readline) {
6+
const n = readline();
7+
8+
// Write an answer using console.log()
9+
// To debug: console.error('Debug messages...');
10+
11+
console.log('nth_solid');
12+
}
13+
14+
export { execute };
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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/solidInteger/solidInteger.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Solid integer", 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("Starting small", function() {
22+
let inputFile = new File(__dirname + 'input/01 - starting small.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
11
29+
);
30+
});
31+
32+
test("Medium test", function() {
33+
let inputFile = new File(__dirname + 'input/02 - medium test.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
121
40+
);
41+
});
42+
43+
test("100k", function() {
44+
let inputFile = new File(__dirname + 'input/03 - 100k.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
162151
51+
);
52+
});
53+
54+
test("Smart solution", function() {
55+
let inputFile = new File(__dirname + 'input/04 - smart solution.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
23776826742147167
62+
);
63+
});
64+
65+
test("Output might overflow", function() {
66+
let inputFile = new File(__dirname + 'input/05 - output might overflow.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assert.strictEqual(
71+
console.log.getCall(0).args[0],
72+
33646585979948395414
73+
);
74+
});
75+
76+
test("Single digit", function() {
77+
let inputFile = new File(__dirname + 'input/06 - single digit.txt');
78+
79+
execute(inputFile.readline.bind(inputFile));
80+
81+
assert.strictEqual(
82+
console.log.getCall(0).args[0],
83+
9
84+
);
85+
});
86+
87+
test("Another small", function() {
88+
let inputFile = new File(__dirname + 'input/07 - another small.txt');
89+
90+
execute(inputFile.readline.bind(inputFile));
91+
92+
assert.strictEqual(
93+
console.log.getCall(0).args[0],
94+
98
95+
);
96+
});
97+
98+
test("Another medium", function() {
99+
let inputFile = new File(__dirname + 'input/08 - another medium.txt');
100+
101+
execute(inputFile.readline.bind(inputFile));
102+
103+
assert.strictEqual(
104+
console.log.getCall(0).args[0],
105+
919
106+
);
107+
});
108+
109+
test("Another large", function() {
110+
let inputFile = new File(__dirname + 'input/09 - another large.txt');
111+
112+
execute(inputFile.readline.bind(inputFile));
113+
114+
assert.strictEqual(
115+
console.log.getCall(0).args[0],
116+
888889
117+
);
118+
});
119+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
100
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
100000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4503599627370496
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4611686018427387904
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
89

0 commit comments

Comments
 (0)