Skip to content

Commit 3152779

Browse files
committed
Adding tests for "Regular polygons".
1 parent 5faefad commit 3152779

File tree

8 files changed

+96
-0
lines changed

8 files changed

+96
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Tests for "Hacking at RobberCity".
2323
- Tests for "Box of cigars".
2424
- Tests for "Simplified Monopoly™ turns prediction".
25+
- Tests for "Regular polygons".
2526

2627
## [1.13.0] - 2022-09-30
2728
### Added
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* The "Regular polygons" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/regular-polygons}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const a = parseInt(inputs[0]);
8+
const b = parseInt(inputs[1]);
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('answer');
14+
}
15+
16+
export { execute };
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/regularPolygons/regularPolygons.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Regular polygons", 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("Example", function() {
21+
let inputFile = new File(__dirname + 'input/01 - example.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
4
28+
);
29+
});
30+
31+
test("Shortest range", function() {
32+
let inputFile = new File(__dirname + 'input/02 - shortest range.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
1
39+
);
40+
});
41+
42+
test("Short range", function() {
43+
let inputFile = new File(__dirname + 'input/03 - short range.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
88
50+
);
51+
});
52+
53+
test("Medium range", function() {
54+
let inputFile = new File(__dirname + 'input/04 - medium range.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
199
61+
);
62+
});
63+
64+
test("Long range", function() {
65+
let inputFile = new File(__dirname + 'input/05 - long range.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
494
72+
);
73+
});
74+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 6
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17 17
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10 10000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
15 1000000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 2147483647

0 commit comments

Comments
 (0)