Skip to content

Commit fd6e27d

Browse files
committed
Adding tests for "Darts".
1 parent 969a3d7 commit fd6e27d

File tree

10 files changed

+140
-0
lines changed

10 files changed

+140
-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 "The travelling salesman problem".
2828
- Tests for "Murder in the village!".
2929
- Tests for "Dead men's shot".
30+
- Tests for "Darts".
3031

3132
## [1.7.0] - 2022-03-31
3233
### Added
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* The "Darts" puzzle.
3+
*/
4+
function execute(readline) {
5+
const SIZE = parseInt(readline());
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
const name = readline();
9+
}
10+
const T = parseInt(readline());
11+
for (let i = 0; i < T; i++) {
12+
var inputs = readline().split(' ');
13+
const throwName = inputs[0];
14+
const throwX = parseInt(inputs[1]);
15+
const throwY = parseInt(inputs[2]);
16+
}
17+
18+
// Write an answer using console.log()
19+
// To debug: console.error('Debug messages...');
20+
21+
console.log('answer');
22+
}
23+
24+
export { execute };
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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/easy/darts/darts.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Darts", 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("Hit and miss duos", function() {
22+
let inputFile = new File(__dirname + 'input/01 - hit and miss duos.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - hit and miss duos.txt');
27+
});
28+
29+
test("Solo play", function() {
30+
let inputFile = new File(__dirname + 'input/02 - Solo play.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assert.strictEqual(
35+
console.log.getCall(0).args[0],
36+
"Will 30"
37+
);
38+
});
39+
40+
test("Chaotic Ties", function() {
41+
let inputFile = new File(__dirname + 'input/03 - chaotic ties.txt');
42+
43+
execute(inputFile.readline.bind(inputFile));
44+
45+
assertOutputAnswer(__dirname + 'output/03 - chaotic ties.txt');
46+
});
47+
48+
test("Circles", function() {
49+
let inputFile = new File(__dirname + 'input/04 - circles.txt');
50+
51+
execute(inputFile.readline.bind(inputFile));
52+
53+
assertOutputAnswer(__dirname + 'output/04 - circles.txt');
54+
});
55+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
20
2+
2
3+
Will
4+
Jill
5+
4
6+
Will 0 0
7+
Jill 0 0
8+
Will 20 20
9+
Jill 0 0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
20
2+
1
3+
Will
4+
3
5+
Will -10 10
6+
Will -5 7
7+
Will 0 0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
20
2+
5
3+
Eric
4+
Joe
5+
Molly
6+
Louis
7+
Brandon
8+
10
9+
Joe 0 0
10+
Molly 0 0
11+
Brandon 0 0
12+
Eric -50 50
13+
Louis 50 -50
14+
Joe 10 10
15+
Molly -10 10
16+
Brandon -10 -10
17+
Eric 5 5
18+
Louis 0 0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
100
2+
4
3+
Will
4+
Bill
5+
Jill
6+
Rekt
7+
8
8+
Will -51 0
9+
Bill 51 0
10+
Jill 49 2
11+
Rekt 0 0
12+
Will 35 35
13+
Bill -20 -21
14+
Jill 1 50
15+
Rekt -13 39
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Jill 30
2+
Will 15
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Joe 20
2+
Molly 20
3+
Brandon 20
4+
Eric 15
5+
Louis 15
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Rekt 25
2+
Bill 15
3+
Jill 15
4+
Will 10

0 commit comments

Comments
 (0)