Skip to content

Commit 68cbc06

Browse files
committed
Adding tests for "Dwarfs standing on the shoulders of giants".
1 parent 1b319b4 commit 68cbc06

File tree

6 files changed

+93
-0
lines changed

6 files changed

+93
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- Tests for "Conway sequence".
10+
- Tests for "Dwarfs standing on the shoulders of giants".
1011

1112
## [1.1.0] - 2022-02-28
1213
### Added
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* The "Dwarfs standing on the shoulders of giants" puzzle.
3+
*/
4+
function execute(readline) {
5+
const n = parseInt(readline()); // the number of relationships of influence
6+
for (let i = 0; i < n; i++) {
7+
var inputs = readline().split(' ');
8+
const x = parseInt(inputs[0]); // a relationship of influence between two people (x influences y)
9+
const y = parseInt(inputs[1]);
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
16+
// The number of people involved in the longest succession of influences
17+
console.log('2');
18+
}
19+
20+
export { execute };
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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/training/medium/dwarfsStandingOnTheShouldersOfGiants/dwarfsStandingOnTheShouldersOfGiants.js';
6+
7+
/**
8+
* Tests for the "Dwarfs standing on the shoulders of giants" puzzle.
9+
*/
10+
suite('Dwarfs standing on the shoulders of giants', function() {
11+
const sandbox = sinon.createSandbox();
12+
13+
setup(function () {
14+
sandbox.stub(console, "log");
15+
});
16+
17+
teardown(function () {
18+
sandbox.restore();
19+
});
20+
21+
22+
test('Simple example', function() {
23+
let inputFile = new File('./test/training/medium/dwarfsStandingOnTheShouldersOfGiants/input/01 - simple example.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assert.strictEqual(
28+
console.log.getCall(0).args[0],
29+
3
30+
);
31+
});
32+
33+
test('Complete example', function() {
34+
let inputFile = new File('./test/training/medium/dwarfsStandingOnTheShouldersOfGiants/input/02 - complete example.txt');
35+
36+
execute(inputFile.readline.bind(inputFile));
37+
38+
assert.strictEqual(
39+
console.log.getCall(0).args[0],
40+
4
41+
);
42+
});
43+
44+
test('Several mentors', function() {
45+
let inputFile = new File('./test/training/medium/dwarfsStandingOnTheShouldersOfGiants/input/03 - several mentors.txt');
46+
47+
execute(inputFile.readline.bind(inputFile));
48+
49+
assert.strictEqual(
50+
console.log.getCall(0).args[0],
51+
3
52+
);
53+
});
54+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
1 2
3+
1 3
4+
3 4
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
1 2
3+
1 3
4+
3 4
5+
2 4
6+
2 5
7+
10 11
8+
10 1
9+
10 3
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
2 3
3+
8 9
4+
1 2
5+
6 3

0 commit comments

Comments
 (0)