Skip to content

Commit d899681

Browse files
committed
Adding tests for "Dead men's shot".
1 parent 1c3156a commit d899681

File tree

13 files changed

+126
-19
lines changed

13 files changed

+126
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Tests for "The mystic rectangle".
2727
- Tests for "The travelling salesman problem".
2828
- Tests for "Murder in the village!".
29+
- Tests for "Dead men's shot".
2930

3031
## [1.7.0] - 2022-03-31
3132
### Added
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
/**
2-
* The "Credit card verifier (Luhn’s algorithm)" puzzle.
2+
* The "Dead men's shot" puzzle.
33
*/
44
function execute(readline) {
5-
const n = parseInt(readline());
6-
for (let i = 0; i < n; i++) {
7-
const card = readline();
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
var inputs = readline().split(' ');
8+
const x = parseInt(inputs[0]);
9+
const y = parseInt(inputs[1]);
10+
}
11+
const M = parseInt(readline());
12+
for (let i = 0; i < M; i++) {
13+
var inputs = readline().split(' ');
14+
const x = parseInt(inputs[0]);
15+
const y = parseInt(inputs[1]);
816
}
917

1018
// Write an answer using console.log()
1119
// To debug: console.error('Debug messages...');
1220

13-
console.log('YES or NO');
21+
console.log('hit_or_miss');
1422
}
1523

1624
export { execute };

test/community/training/easy/deadMensShot/CGTest.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { assert } from 'chai';
22
import sinon from 'sinon';
33
import File from '../../../../File.js';
44
import { assertOutputAnswer } from '../../../../assertOutputAnswer.js';
5-
import { execute } from '../../../../../lib/community/training/easy/creditCardVerifier/creditCardVerifier.js';
5+
import { execute } from '../../../../../lib/community/training/easy/deadMensShot/deadMensShot.js';
66

77
const __dirname = new URL('.', import.meta.url).pathname;
88

9-
suite('Container terminal', function() {
9+
suite("Dead men's shot", function() {
1010
const sandbox = sinon.createSandbox();
1111

1212
setup(function () {
@@ -18,35 +18,43 @@ suite('Container terminal', function() {
1818
});
1919

2020

21-
test('Tests', function() {
22-
let inputFile = new File(__dirname + 'input/01 - tests.txt');
21+
test("Square", function() {
22+
let inputFile = new File(__dirname + 'input/01 - square.txt');
2323

2424
execute(inputFile.readline.bind(inputFile));
2525

26-
assertOutputAnswer(__dirname + 'output/01 - tests.txt');
26+
assertOutputAnswer(__dirname + 'output/01 - square.txt');
2727
});
2828

29-
test('MasterCard', function() {
30-
let inputFile = new File(__dirname + 'input/02 - MasterCard.txt');
29+
test("Triangle", function() {
30+
let inputFile = new File(__dirname + 'input/02 - triangle.txt');
3131

3232
execute(inputFile.readline.bind(inputFile));
3333

34-
assertOutputAnswer(__dirname + 'output/02 - MasterCard.txt');
34+
assertOutputAnswer(__dirname + 'output/02 - triangle.txt');
3535
});
3636

37-
test('Discover', function() {
38-
let inputFile = new File(__dirname + 'input/03 - Discover.txt');
37+
test("Five corners", function() {
38+
let inputFile = new File(__dirname + 'input/03 - five corners.txt');
3939

4040
execute(inputFile.readline.bind(inputFile));
4141

42-
assertOutputAnswer(__dirname + 'output/03 - Discover.txt');
42+
assertOutputAnswer(__dirname + 'output/03 - five corners.txt');
4343
});
4444

45-
test('VISA', function() {
46-
let inputFile = new File(__dirname + 'input/04 - VISA.txt');
45+
test("Six sides", function() {
46+
let inputFile = new File(__dirname + 'input/04 - six sides.txt');
4747

4848
execute(inputFile.readline.bind(inputFile));
4949

50-
assertOutputAnswer(__dirname + 'output/04 - VISA.txt');
50+
assertOutputAnswer(__dirname + 'output/04 - six sides.txt');
51+
});
52+
53+
test("Ten sides", function() {
54+
let inputFile = new File(__dirname + 'input/05 - ten sides.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - ten sides.txt');
5159
});
5260
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
4
2+
-100 -100
3+
100 -100
4+
100 100
5+
-100 100
6+
5
7+
0 0
8+
99 99
9+
101 101
10+
80 -101
11+
0 -100
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
3
2+
0 0
3+
400 0
4+
200 200
5+
5
6+
200 100
7+
-34 23
8+
75 5
9+
175 174
10+
175 176
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
5
2+
0 0
3+
100 0
4+
150 50
5+
100 100
6+
0 100
7+
5
8+
100 50
9+
20 80
10+
150 0
11+
99 99
12+
125 76
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
6
2+
0 0
3+
100 -1000
4+
500 0
5+
500 100
6+
400 1000
7+
0 100
8+
5
9+
300 100
10+
5 -666
11+
100 -666
12+
250 250
13+
400 -400
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
10
2+
0 0
3+
100 0
4+
150 25
5+
200 75
6+
150 100
7+
100 125
8+
50 125
9+
-50 100
10+
-60 50
11+
-50 25
12+
6
13+
50 80
14+
100 100
15+
-100 80
16+
0 120
17+
200 100
18+
175 60
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
hit
2+
hit
3+
miss
4+
miss
5+
hit
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
hit
2+
miss
3+
hit
4+
hit
5+
miss

0 commit comments

Comments
 (0)