Skip to content

Commit 04663a6

Browse files
committed
Adding tests for "Super computer".
1 parent 29f51d0 commit 04663a6

File tree

6 files changed

+100083
-0
lines changed

6 files changed

+100083
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Tests for "CGX formatter".
1212
- Tests for "Genome sequencing".
1313
- Tests for "Roller coaster".
14+
- Tests for "Super computer".
1415

1516
## [1.3.0] - 2022-03-02
1617
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Super computer" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
var inputs = readline().split(' ');
8+
const J = parseInt(inputs[0]);
9+
const D = parseInt(inputs[1]);
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
export { execute };
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../File.js';
4+
import { execute } from '../../../../lib/training/hard/superComputer/superComputer.js';
5+
6+
/**
7+
* Tests for the "Super computer" puzzle.
8+
*/
9+
suite('Super computer', 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 1', function() {
22+
let inputFile = new File('./test/training/hard/superComputer/input/01 - example 1.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
3
29+
);
30+
});
31+
32+
test('Example 2', function() {
33+
let inputFile = new File('./test/training/hard/superComputer/input/02 - example 2.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
4
40+
);
41+
});
42+
43+
test('Large number of scientists', function() {
44+
let inputFile = new File('./test/training/hard/superComputer/input/03 - large number of scientists.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
7879
51+
);
52+
});
53+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
2 5
3+
9 7
4+
15 6
5+
9 3
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
3 5
3+
9 2
4+
24 5
5+
16 9
6+
11 6

0 commit comments

Comments
 (0)