Skip to content

Commit 9cdc0aa

Browse files
committed
Adding tests for "Find the replacement".
1 parent 47e63cc commit 9cdc0aa

File tree

12 files changed

+123
-0
lines changed

12 files changed

+123
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Tests for "Let's go to the cinema!".
2929
- Tests for "ASCII ART : glass stacking".
3030
- Tests for "De-FizzBuzzer".
31+
- Tests for "Find the replacement".
3132

3233
## [1.16.0] - 2022-12-31
3334
### Added
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* The "Find the replacement" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/find-the-replacement}
4+
*/
5+
function execute(readline) {
6+
const X = readline();
7+
const Y = readline();
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
console.log('anwser');
13+
}
14+
15+
export { execute };
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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/findTheReplacement/findTheReplacement.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Find the replacement", 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("Easy replacement", function() {
22+
let inputFile = new File(__dirname + 'input/01 - easy replacement.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - easy replacement.txt');
27+
});
28+
29+
test("No replacement", function() {
30+
let inputFile = new File(__dirname + 'input/02 - no replacement.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assert.strictEqual(
35+
console.log.getCall(0).args[0],
36+
"NONE"
37+
);
38+
});
39+
40+
test("CAN'T (hard)", function() {
41+
let inputFile = new File(__dirname + 'input/03 - CAN\'T (hard).txt');
42+
43+
execute(inputFile.readline.bind(inputFile));
44+
45+
assert.strictEqual(
46+
console.log.getCall(0).args[0],
47+
"CAN'T"
48+
);
49+
});
50+
51+
test("Symbols", function() {
52+
let inputFile = new File(__dirname + 'input/04 - symbols.txt');
53+
54+
execute(inputFile.readline.bind(inputFile));
55+
56+
assertOutputAnswer(__dirname + 'output/04 - symbols.txt');
57+
});
58+
59+
test("Random, all different", function() {
60+
let inputFile = new File(__dirname + 'input/05 - random, all different.txt');
61+
62+
execute(inputFile.readline.bind(inputFile));
63+
64+
assertOutputAnswer(__dirname + 'output/05 - random, all different.txt');
65+
});
66+
67+
test("Symbols reversed", function() {
68+
let inputFile = new File(__dirname + 'input/06 - symbols reversed.txt');
69+
70+
execute(inputFile.readline.bind(inputFile));
71+
72+
assert.strictEqual(
73+
console.log.getCall(0).args[0],
74+
"CAN'T"
75+
);
76+
});
77+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BARTENDER
2+
CARBENDER
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Statement
2+
Statement
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TARGET
2+
THRONE
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!_@...@@..@@@!$$#@@$$@._####!##...!!!@@@!!!@@$$....@@!!!$$$$!!##@!$$#!@@.###
2+
!_$###$$##$$$!$$#$$$$$#_####!#####!!!$$$!!!$$$$####$$!!!$$$$!!##$!$$#!$$####
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
i pdnwspak aeeomaegant ganwua ediap ons
2+
yzzdhfkzfdzfjjfkfjkfhzzkfhfzfzjdyfzzfhk
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!_$###$$##$$$!$$#$$$$$#_####!#####!!!$$$!!!$$$$####$$!!!$$$$!!##$!$$#!$$####
2+
!_@...@@..@@@!$$#@@$$@._####!##...!!!@@@!!!@@$$....@@!!!$$$$!!##@!$$#!@@.###
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
B->C
2+
T->B

0 commit comments

Comments
 (0)