Skip to content

Commit a3ff08f

Browse files
committed
Adding tests for "Ghost legs".
1 parent 9d1240c commit a3ff08f

File tree

15 files changed

+244
-0
lines changed

15 files changed

+244
-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 "ISBN check digit".
1212
- Tests for "Equivalent resistance, circuit building".
1313
- Tests for "1D spreadsheet".
14+
- Tests for "Ghost legs".
1415

1516
### Changed
1617
- Using "__dirname" for input / output paths.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Ghost legs" puzzle.
3+
*/
4+
function execute(readline) {
5+
var inputs = readline().split(' ');
6+
const W = parseInt(inputs[0]);
7+
const H = parseInt(inputs[1]);
8+
for (let i = 0; i < H; i++) {
9+
const line = readline();
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: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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/ghostLegs/ghostLegs.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
/**
10+
* Tests for the "Ghost legs" puzzle.
11+
*/
12+
suite("Ghost legs", function() {
13+
const sandbox = sinon.createSandbox();
14+
15+
setup(function () {
16+
sandbox.stub(console, "log");
17+
});
18+
19+
teardown(function () {
20+
sandbox.restore();
21+
});
22+
23+
24+
test('Simple sample', function() {
25+
let inputFile = new File(__dirname + 'input/01 - simple sample.txt');
26+
27+
execute(inputFile.readline.bind(inputFile));
28+
29+
assertOutputAnswer(__dirname + 'output/01 - simple sample.txt');
30+
});
31+
32+
test('Small sample', function() {
33+
let inputFile = new File(__dirname + 'input/02 - small sample.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assertOutputAnswer(__dirname + 'output/02 - small sample.txt');
38+
});
39+
40+
test('6 lanes', function() {
41+
let inputFile = new File(__dirname + 'input/03 - 6 lanes.txt');
42+
43+
execute(inputFile.readline.bind(inputFile));
44+
45+
assertOutputAnswer(__dirname + 'output/03 - 6 lanes.txt');
46+
});
47+
48+
test('8 lanes', function() {
49+
let inputFile = new File(__dirname + 'input/04 - 8 lanes.txt');
50+
51+
execute(inputFile.readline.bind(inputFile));
52+
53+
assertOutputAnswer(__dirname + 'output/04 - 8 lanes.txt');
54+
});
55+
56+
test('10 lanes', function() {
57+
let inputFile = new File(__dirname + 'input/05 - 10 lanes.txt');
58+
59+
execute(inputFile.readline.bind(inputFile));
60+
61+
assertOutputAnswer(__dirname + 'output/05 - 10 lanes.txt');
62+
});
63+
64+
test('Wide and wild', function() {
65+
let inputFile = new File(__dirname + 'input/06 - wide and wild.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assertOutputAnswer(__dirname + 'output/06 - wide and wild.txt');
70+
});
71+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7 7
2+
A B C
3+
| | |
4+
|--| |
5+
| |--|
6+
| |--|
7+
| | |
8+
1 2 3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
13 8
2+
A B C D E
3+
| | | | |
4+
| |--| | |
5+
|--| | | |
6+
| | |--| |
7+
| |--| |--|
8+
| | | | |
9+
1 2 3 4 5
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
16 14
2+
F E D C B A
3+
| |--| | | |
4+
|--| |--| |--|
5+
| |--| |--| |
6+
| | | | |--|
7+
| |--| |--| |
8+
| | |--| | |
9+
| | |--| |--|
10+
|--| | |--| |
11+
| | |--| | |
12+
|--| | | |--|
13+
| |--| | | |
14+
| | |--| | |
15+
0 1 2 3 4 5
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
22 18
2+
P Q R S T U V W
3+
| | | | |--| | |
4+
| | |--| | | |--|
5+
| |--| |--| | | |
6+
|--| |--| | | |--|
7+
|--| | | | |--| |
8+
| |--| | |--| |--|
9+
| | | |--| |--| |
10+
|--| | | |--| | |
11+
| | |--| | | | |
12+
| | | |--| | |--|
13+
| | | | |--| | |
14+
|--| | | | | | |
15+
|--| |--| | | |--|
16+
| |--| | |--| | |
17+
| | |--| | | |--|
18+
|--| |--| | |--| |
19+
1 2 3 4 5 6 7 8
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
28 20
2+
A B C D E F G H I J
3+
|--| |--| |--| |--| |--|
4+
| |--| |--| |--| |--| |
5+
|--| |--| |--| |--| |--|
6+
|--| |--| |--| |--| |--|
7+
| |--| |--| |--| |--| |
8+
| |--| |--| |--| |--| |
9+
|--| |--| |--| |--| |--|
10+
|--| |--| |--| |--| |--|
11+
| |--| |--| |--| |--| |
12+
|--| |--| |--| |--| |--|
13+
| |--| |--| |--| |--| |
14+
|--| |--| |--| |--| |--|
15+
|--| |--| |--| |--| |--|
16+
|--| |--| |--| |--| |--|
17+
| |--| |--| |--| |--| |
18+
|--| |--| |--| |--| |--|
19+
|--| |--| |--| |--| |--|
20+
| |--| |--| |--| |--| |
21+
0 1 2 3 4 5 6 7 8 9
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
76 23
2+
~ ! @ # $ % ^ & * ( ) + ` 1 2 3 4 5 6 7 8 9 0 = \ /
3+
| |--| | |--| | |--| |--| | |--| | | |--| |--| | |--| | |--|
4+
|--| |--| | | |--| |--| |--| | | |--| | |--| |--| | | |--| |
5+
| |--| |--| | | | | |--| |--| | | | |--| |--| |--| |--| |--|
6+
|--| |--| | | |--| |--| |--| | | |--| |--| |--| | | |--| |--|
7+
|--| | | | |--| | |--| | | | |--| |--| |--| |--| |--| |--| |
8+
| |--| | |--| |--| | |--| | |--| |--| | | |--| | |--| |--| |
9+
| | | |--| |--| |--| | | |--| |--| | |--| |--| |--| |--| |--|
10+
|--| | | |--| |--| |--| | | |--| |--| |--| | |--| | |--| |--|
11+
| | |--| | | | |--| | |--| | | | | | |--| | | |--| |--| |
12+
| | | |--| | |--| | | | |--| | |--| |--| |--| |--| |--| |--|
13+
| |--| |--| | | | | |--| |--| | | | |--| |--| |--| |--| |--|
14+
|--| |--| | | |--| |--| |--| | | |--| |--| |--| | | |--| |--|
15+
|--| | | | |--| | |--| | | | |--| |--| |--| |--| |--| |--| |
16+
|--| |--| | | |--| |--| |--| | | |--| | |--| | | |--| | |--|
17+
| |--| | |--| |--| | |--| | |--| |--| | | |--| | |--| |--| |
18+
| |--| | |--| | | | |--| | |--| | |--| |--| |--| |--| |--| |
19+
|--| | |--| | | | |--| | |--| |--| | |--| |--| |--| |--| |--|
20+
|--| |--| | | |--| |--| |--| | | |--| | |--| | | |--| | |--|
21+
| |--| | |--| | |--| |--| | | |--| |--| | |--| |--| |--| |--|
22+
| | | |--| | |--| | | | |--| | |--| | |--| |--| |--| |--| |
23+
|--| |--| |--| |--| |--| |--| |--| |--| |--| |--| | | | | |--|
24+
a A b B c C d D e E f F g G h H i I j J k K l L m M
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
A2
2+
B1
3+
C3

0 commit comments

Comments
 (0)