Skip to content

Commit 1243e43

Browse files
committed
Adding tests for "English length units
conversion".
1 parent f46a69d commit 1243e43

File tree

7 files changed

+155
-0
lines changed

7 files changed

+155
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Tests for "Battle tower".
3333
- Tests for "OneWay city".
3434
- Tests for "Plague, jr".
35+
- Tests for "English length units conversion".
3536

3637
## [1.14.0] - 2022-10-31
3738
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "English length units conversion" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/english-length-units-conversion}
4+
*/
5+
function execute(readline) {
6+
const toconvert = readline();
7+
const n = parseInt(readline());
8+
for (let i = 0; i < n; i++) {
9+
const relation = readline();
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('result');
16+
}
17+
18+
export { execute };
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/englishLengthUnitsConversion/englishLengthUnitsConversion.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("English length units conversion", function() {
9+
const sandbox = sinon.createSandbox();
10+
11+
setup(function () {
12+
sandbox.stub(console, "log");
13+
});
14+
15+
teardown(function () {
16+
sandbox.restore();
17+
});
18+
19+
20+
test("Direct relations", function() {
21+
let inputFile = new File(__dirname + 'input/01 - direct relations.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"1 inch = 1440 twip"
28+
);
29+
});
30+
31+
test("Direct relations with dead end", function() {
32+
let inputFile = new File(__dirname + 'input/02 - direct relations with dead end.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"1440 twip = 1 inch"
39+
);
40+
});
41+
42+
test("With loops", function() {
43+
let inputFile = new File(__dirname + 'input/03 - with loops.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"1440 twip = 1 inch"
50+
);
51+
});
52+
53+
test("Full tree", function() {
54+
let inputFile = new File(__dirname + 'input/04 - full tree.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"5 spindle = 12 league"
61+
);
62+
});
63+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
inch in twip
2+
3
3+
1 point = 20 twip
4+
1 inch = 12 line
5+
1 line = 6 point
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
twip in inch
2+
4
3+
1 point = 20 twip
4+
1 line = 6 point
5+
1 inch = 12 line
6+
1 inch = 6 pica
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
twip in inch
2+
11
3+
1 point = 20 twip
4+
1 pica = 12 point
5+
1 line = 6 point
6+
1 inch = 12 line
7+
1 inch = 6 pica
8+
1 poppyseed = 1 line
9+
1 barleycorn = 4 poppyseed
10+
1 finger = 63 point
11+
8 finger = 7 inch
12+
1 inch = 3 barleycorn
13+
1 stick = 2 inch
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
spindle in league
2+
47
3+
1 point = 20 twip
4+
1 pica = 12 point
5+
1 line = 6 point
6+
1 inch = 12 line
7+
1 inch = 6 pica
8+
1 poppyseed = 1 line
9+
1 barleycorn = 4 poppyseed
10+
1 finger = 63 point
11+
8 finger = 7 inch
12+
1 inch = 3 barleycorn
13+
1 stick = 2 inch
14+
1 hand = 2 stick
15+
1 foot = 3 hand
16+
1 foot = 12 inch
17+
1 yard = 3 foot
18+
1 foot = 2 shaftment
19+
1 shaftment = 2 palm
20+
1 palm = 3 inch
21+
1 palm = 4 digit
22+
1 nail = 3 digit
23+
1 span = 4 nail
24+
1 span = 3 palm
25+
1 cubit = 2 span
26+
1 cubit = 3 shaftment
27+
1 ell = 5 span
28+
1 skein = 96 ell
29+
1 spindle = 120 skein
30+
1 pace = 5 shaftment
31+
1 grade = 2 pace
32+
1 step = 1 grade
33+
1 rope = 4 step
34+
1 Ramsden's chain = 5 rope
35+
1 Roman mile = 120 Ramsden's chain
36+
1 rod = 11 cubit
37+
1 rod = 25 link
38+
1 pole = 1 rod
39+
1 perch = 1 pole
40+
1 Gunter's chain = 4 rod
41+
1 furlong = 10 Gunter's chain
42+
1 mile = 8 furlong
43+
1 mile = 1760 yard
44+
1 yard = 2 cubit
45+
1 fathom = 2 yard
46+
1 shackle = 15 fathom
47+
1 cable = 100 fathom
48+
1 nautic mile = 10 cable
49+
1 league = 3 nautic mile

0 commit comments

Comments
 (0)