Skip to content

Commit 130da65

Browse files
committed
Adding tests for "2nd degree polynomial -
simple analysis".
1 parent cdffa05 commit 130da65

File tree

9 files changed

+110
-0
lines changed

9 files changed

+110
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Tests for "Detective geek".
3434
- Tests for "Largest number".
3535
- Tests for "Smooth!".
36+
- Tests for "2nd degree polynomial - simple analysis".
3637

3738
## [1.9.0] - 2022-06-01
3839
### Added
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "2nd degree polynomial - simple analysis" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/2nd-degree-polynomial---simple-analysis}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const a = parseFloat(inputs[0]);
8+
const b = parseFloat(inputs[1]);
9+
const c = parseFloat(inputs[2]);
10+
11+
// Write an answer using console.log()
12+
// To debug: console.error('Debug messages...');
13+
14+
console.log('(X1,Y1),...,(Xn,Yn)');
15+
}
16+
17+
export { execute };
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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/secondDegreePolynomialSimpleAnalysis/secondDegreePolynomialSimpleAnalysis.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("2nd degree polynomial - simple analysis", 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("Centered parabol, 1 intersection", function() {
22+
let inputFile = new File(__dirname + 'input/01 - centered parabol, 1 intersection.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
"(0,1)"
29+
);
30+
});
31+
32+
test("Horizontal line, 1 intersection to be rounded", function() {
33+
let inputFile = new File(__dirname + 'input/02 - horizontal line, 1 intersection to be rounded.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
"(0,1.34)"
40+
);
41+
});
42+
43+
test("Straight line, 2 intersections", function() {
44+
let inputFile = new File(__dirname + 'input/03 - straight line, 2 intersections.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
"(0,2),(2,0)"
51+
);
52+
});
53+
54+
test("Centered parabol, 3 intersections", function() {
55+
let inputFile = new File(__dirname + 'input/04 - centered parabol, 3 intersections.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
"(-0.5,0),(0,-0.75),(0.5,0)"
62+
);
63+
});
64+
65+
test("Parabol on the right, 2 intersections", function() {
66+
let inputFile = new File(__dirname + 'input/05 - parabol on the right, 2 intersections.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assert.strictEqual(
71+
console.log.getCall(0).args[0],
72+
"(0,1),(1,0)"
73+
);
74+
});
75+
76+
test("Special case", function() {
77+
let inputFile = new File(__dirname + 'input/06 - special case.txt');
78+
79+
execute(inputFile.readline.bind(inputFile));
80+
81+
assert.strictEqual(
82+
console.log.getCall(0).args[0],
83+
"(0,0)"
84+
);
85+
});
86+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 0 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0 0 1.3357
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0 -1 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 0 -0.75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 -2 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0 0 0

0 commit comments

Comments
 (0)