Skip to content

Commit 6ad8ba7

Browse files
committed
Adding tests for "1×1×1 rubik’s
cube movements".
1 parent ec5106e commit 6ad8ba7

File tree

15 files changed

+117
-1
lines changed

15 files changed

+117
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [1.9.0] - 2022-06-01
88
### Added
99
- Tests for "XML MDF-2016".
1010
- Tests for "Brick in the wall".
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737
- Tests for "Linear bézier curves".
3838
- Tests for "Disordered first contact".
3939
- Tests for "Cosmic love".
40+
- Tests for "1×1×1 rubik’s cube movements".
4041

4142
### Changed
4243
- Docker Node image from "14.16.1-alpine" to "node:16.14.2-alpine".
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "1×1×1 rubik’s cube movements" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/111-rubiks-cube-movements}
4+
*/
5+
function execute(readline) {
6+
const rotations = readline();
7+
const face1 = readline();
8+
const face2 = readline();
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('face1');
14+
console.log('face2');
15+
}
16+
17+
export { execute };
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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/oneByOneByOneRubiksCubeMovements/oneByOneByOneRubiksCubeMovements.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("1×1×1 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("One rotation", function() {
22+
let inputFile = new File(__dirname + 'input/01 - one rotation.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - one rotation.txt');
27+
});
28+
29+
test("Two rotations", function() {
30+
let inputFile = new File(__dirname + 'input/02 - two rotations.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - two rotations.txt');
35+
});
36+
37+
test("Give me five!", function() {
38+
let inputFile = new File(__dirname + 'input/03 - give me five.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - give me five.txt');
43+
});
44+
45+
test("Identity", function() {
46+
let inputFile = new File(__dirname + 'input/04 - identity.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - identity.txt');
51+
});
52+
53+
test("A long route", function() {
54+
let inputFile = new File(__dirname + 'input/05 - a long route.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - a long route.txt');
59+
});
60+
61+
test("Stuttering", function() {
62+
let inputFile = new File(__dirname + 'input/06 - stuttering.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - stuttering.txt');
67+
});
68+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
z
2+
D
3+
L
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
y z'
2+
B
3+
D
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x y x' z y'
2+
L
3+
B
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x y x y x y
2+
F
3+
D
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x y z x z y y x z y z x z x y z y x
2+
L
3+
F
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x x x y y y z z z
2+
B
3+
U
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
L
2+
U

0 commit comments

Comments
 (0)