Skip to content

Commit cd3ff7b

Browse files
committed
Adding tests for "2×2×2 rubik’s cube
movements".
1 parent 3beeb5f commit cd3ff7b

File tree

11 files changed

+79
-0
lines changed

11 files changed

+79
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Tests for "De-FizzBuzzer".
3131
- Tests for "Find the replacement".
3232
- Tests for "The urinal problem".
33+
- Tests for "2×2×2 rubik’s cube movements".
3334

3435
## [1.16.0] - 2022-12-31
3536
### Added
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* The "2×2×2 rubik’s cube movements" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/222-rubiks-cube-movements}
4+
*/
5+
function execute(readline) {
6+
const move = readline();
7+
8+
// Write an answer using console.log()
9+
// To debug: console.error('Debug messages...');
10+
11+
console.log('answer');
12+
}
13+
14+
export { execute };
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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/twoByTwoByTwoRubiksCubeMovements/twoByTwoByTwoRubiksCubeMovements.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("2×2×2 rubik’s cube movements", 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("Simple move", function() {
22+
let inputFile = new File(__dirname + 'input/01 - simple move.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - simple move.txt');
27+
});
28+
29+
test("Reverse move", function() {
30+
let inputFile = new File(__dirname + 'input/02 - reverse move.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - reverse move.txt');
35+
});
36+
37+
test("Square move", function() {
38+
let inputFile = new File(__dirname + 'input/03 - square move.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - square move.txt');
43+
});
44+
45+
test("Classical algorithms", function() {
46+
let inputFile = new File(__dirname + 'input/04 - classical algorithms.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - classical algorithms.txt');
51+
});
52+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
R
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
R'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
U2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
R2L2UD'.F2B2UD'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FD
2+
FD
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FU
2+
FU
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BB
2+
FF

0 commit comments

Comments
 (0)