Skip to content

Commit 5c9a7dc

Browse files
committed
Adding tests for "Mitosis mayhem".
1 parent f5f0ef5 commit 5c9a7dc

26 files changed

+233
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737
- Tests for "A coin guessing game".
3838
- Tests for "Folding a note".
3939
- Tests for "River crossing".
40+
- Tests for "Mitosis mayhem".
4041

4142
## [1.11.0] - 2022-07-31
4243
### Added
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* The "Mitosis mayhem" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/mitosis-mayhem}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const max = parseInt(inputs[0]);
8+
const cycles = parseInt(inputs[1]);
9+
for (let i = 0; i < cycles; i++) {
10+
var inputs = readline().split(' ');
11+
const name = inputs[0];
12+
const initialCount = parseInt(inputs[1]);
13+
const power = parseInt(inputs[2]);
14+
}
15+
16+
// Write an answer using console.log()
17+
// To debug: console.error('Debug messages...');
18+
19+
console.log('The Answer: 42');
20+
}
21+
22+
export { execute };
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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/medium/mitosisMayhem/mitosisMayhem.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Mitosis mayhem", 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("All full", function() {
22+
let inputFile = new File(__dirname + 'input/01 - all full.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
"Red: 10"
29+
);
30+
});
31+
32+
test("Missing a few", function() {
33+
let inputFile = new File(__dirname + 'input/02 - missing a few.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assertOutputAnswer(__dirname + 'output/02 - missing a few.txt');
38+
});
39+
40+
test("Multiple", function() {
41+
let inputFile = new File(__dirname + 'input/03 - multiple.txt');
42+
43+
execute(inputFile.readline.bind(inputFile));
44+
45+
assertOutputAnswer(__dirname + 'output/03 - multiple.txt');
46+
});
47+
48+
test("Overflow!", function() {
49+
let inputFile = new File(__dirname + 'input/04 - overflow!.txt');
50+
51+
execute(inputFile.readline.bind(inputFile));
52+
53+
assert.strictEqual(
54+
console.log.getCall(0).args[0],
55+
"OVERFLOW!"
56+
);
57+
});
58+
59+
test("Overflow! 2", function() {
60+
let inputFile = new File(__dirname + 'input/05 - overflow! 2.txt');
61+
62+
execute(inputFile.readline.bind(inputFile));
63+
64+
assert.strictEqual(
65+
console.log.getCall(0).args[0],
66+
"OVERFLOW!"
67+
);
68+
});
69+
70+
test("Stop!", function() {
71+
let inputFile = new File(__dirname + 'input/06 - stop!.txt');
72+
73+
execute(inputFile.readline.bind(inputFile));
74+
75+
assertOutputAnswer(__dirname + 'output/06 - stop!.txt');
76+
});
77+
78+
test("Conflict!", function() {
79+
let inputFile = new File(__dirname + 'input/07 - conflict!.txt');
80+
81+
execute(inputFile.readline.bind(inputFile));
82+
83+
assertOutputAnswer(__dirname + 'output/07 - conflict!.txt');
84+
});
85+
86+
test("Overpowered", function() {
87+
let inputFile = new File(__dirname + 'input/08 - overpowered.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assertOutputAnswer(__dirname + 'output/08 - overpowered.txt');
92+
});
93+
94+
test("Uneven conflict", function() {
95+
let inputFile = new File(__dirname + 'input/09 - uneven conflict.txt');
96+
97+
execute(inputFile.readline.bind(inputFile));
98+
99+
assertOutputAnswer(__dirname + 'output/09 - uneven conflict.txt');
100+
});
101+
102+
test("Consumption", function() {
103+
let inputFile = new File(__dirname + 'input/10 - consumption.txt');
104+
105+
execute(inputFile.readline.bind(inputFile));
106+
107+
assertOutputAnswer(__dirname + 'output/10 - consumption.txt');
108+
});
109+
110+
test("Bigger fish", function() {
111+
let inputFile = new File(__dirname + 'input/11 - bigger fish.txt');
112+
113+
execute(inputFile.readline.bind(inputFile));
114+
115+
assertOutputAnswer(__dirname + 'output/11 - bigger fish.txt');
116+
});
117+
118+
test("Skip the little ones", function() {
119+
let inputFile = new File(__dirname + 'input/12 - skip the little ones.txt');
120+
121+
execute(inputFile.readline.bind(inputFile));
122+
123+
assertOutputAnswer(__dirname + 'output/12 - skip the little ones.txt');
124+
});
125+
126+
test("Imperfect conflict", function() {
127+
let inputFile = new File(__dirname + 'input/13 - imperfect conflict.txt');
128+
129+
execute(inputFile.readline.bind(inputFile));
130+
131+
assertOutputAnswer(__dirname + 'output/13 - imperfect conflict.txt');
132+
});
133+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
10 1
2+
Red 10 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
30 1
2+
Red 10 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
50 2
2+
Red 20 0
3+
Blue 5 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
80 2
2+
Blue 40 0
3+
Green 5 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
50 4
2+
Purple 10 0
3+
Blue 30 0
4+
Green 20 0
5+
Yellow 10 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
50 3
2+
Blue 20 0
3+
STOP! 0 0
4+
Green 10 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
80 3
2+
Red 10 0
3+
Blue 20 0
4+
Nothing 0 0

0 commit comments

Comments
 (0)