Skip to content

Commit 30108a7

Browse files
committed
Adding tests for "Jumping frogs".
1 parent 260d4d7 commit 30108a7

16 files changed

+221
-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 "Number of paths between 2 points".
3434
- Tests for "The lost child.Episode-1".
3535
- Tests for "Gravity tumbler".
36+
- Tests for "Jumping frogs".
3637

3738
## [1.12.0] - 2022-09-01
3839
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "Jumping frogs" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/jumping-frogs}
4+
*/
5+
function execute(readline) {
6+
for (let i = 0; i < 3; i++) {
7+
var inputs = readline().split(' ');
8+
const x = parseInt(inputs[0]);
9+
const y = parseInt(inputs[1]);
10+
const k = parseInt(inputs[2]);
11+
}
12+
13+
// Write an answer using console.log()
14+
// To debug: console.error('Debug messages...');
15+
16+
console.log('Possible');
17+
}
18+
19+
export { execute };
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/jumpingFrogs/jumpingFrogs.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Jumping frogs", 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("Simple jump", function() {
21+
let inputFile = new File(__dirname + 'input/01 - simple jump.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"Possible"
28+
);
29+
});
30+
31+
test("Little stretch", function() {
32+
let inputFile = new File(__dirname + 'input/02 - little stretch.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"Impossible"
39+
);
40+
});
41+
42+
test("Long jump", function() {
43+
let inputFile = new File(__dirname + 'input/03 - long jump.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"Possible"
50+
);
51+
});
52+
53+
test("Javelin jump", function() {
54+
let inputFile = new File(__dirname + 'input/04 - javelin jump.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"Impossible"
61+
);
62+
});
63+
64+
test("Teleport", function() {
65+
let inputFile = new File(__dirname + 'input/05 - teleport.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"Possible"
72+
);
73+
});
74+
75+
test("All i need is jump", function() {
76+
let inputFile = new File(__dirname + 'input/06 - all i need is jump.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"Possible"
83+
);
84+
});
85+
86+
test("Jump for the win", function() {
87+
let inputFile = new File(__dirname + 'input/07 - jump for the win.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"Impossible"
94+
);
95+
});
96+
97+
test("Jump is not enough", function() {
98+
let inputFile = new File(__dirname + 'input/08 - jump is not enough.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"Impossible"
105+
);
106+
});
107+
108+
test("Too many Jumps", function() {
109+
let inputFile = new File(__dirname + 'input/09 - too many Jumps.txt');
110+
111+
execute(inputFile.readline.bind(inputFile));
112+
113+
assert.strictEqual(
114+
console.log.getCall(0).args[0],
115+
"Possible"
116+
);
117+
});
118+
119+
test("Lot of jumps", function() {
120+
let inputFile = new File(__dirname + 'input/10 - lot of jumps.txt');
121+
122+
execute(inputFile.readline.bind(inputFile));
123+
124+
assert.strictEqual(
125+
console.log.getCall(0).args[0],
126+
"Possible"
127+
);
128+
});
129+
130+
test("Fly in the air", function() {
131+
let inputFile = new File(__dirname + 'input/11 - fly in the air.txt');
132+
133+
execute(inputFile.readline.bind(inputFile));
134+
135+
assert.strictEqual(
136+
console.log.getCall(0).args[0],
137+
"Impossible"
138+
);
139+
});
140+
141+
test("Over the mountain", function() {
142+
let inputFile = new File(__dirname + 'input/12 - over the mountain.txt');
143+
144+
execute(inputFile.readline.bind(inputFile));
145+
146+
assert.strictEqual(
147+
console.log.getCall(0).args[0],
148+
"Impossible"
149+
);
150+
});
151+
152+
test("Over the sky", function() {
153+
let inputFile = new File(__dirname + 'input/13 - over the sky.txt');
154+
155+
execute(inputFile.readline.bind(inputFile));
156+
157+
assert.strictEqual(
158+
console.log.getCall(0).args[0],
159+
"Impossible"
160+
);
161+
});
162+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
7 0 1
2+
2 -6 1
3+
-1 0 2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0 -5 2
2+
7 -15 2
3+
-15 1 4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
7294 -7511 18
2+
9084 491 22
3+
492 2627 68
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
6001 9997 75
2+
9604 -9291 92
3+
5722 9238 88
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-2484 -8304 73
2+
5210 -5468 54
3+
-477 -6211 53
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2216 275 53
2+
9077 -5156 95
3+
8662 8134 66
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-2431 8918 88
2+
-9823 -1235 73
3+
6448 1076 50

0 commit comments

Comments
 (0)