Skip to content

Commit 8b643ce

Browse files
committed
Adding tests for "1×1×1 rubik’s
cube movements".
1 parent 53acece commit 8b643ce

File tree

15 files changed

+158
-0
lines changed

15 files changed

+158
-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 "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
## [3.8.0] - 2022-04-30
4243
### Added
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\OneByOneByOneRubiksCubeMovements;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "1×1×1 rubik’s cube movements" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/111-rubiks-cube-movements
12+
*/
13+
class OneByOneByOneRubiksCubeMovements implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
$rotations = stream_get_line($stdin, 100 + 1, "\n");
18+
$face1 = stream_get_line($stdin, 1 + 1, "\n");
19+
$face2 = stream_get_line($stdin, 1 + 1, "\n");
20+
21+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
22+
23+
echo("face1\n");
24+
echo("face2\n");
25+
}
26+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\OneByOneByOneRubiksCubeMovements;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\OneByOneByOneRubiksCubeMovements\OneByOneByOneRubiksCubeMovements;
9+
10+
/**
11+
* Tests for the "1×1×1 rubik’s cube movements" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\OneByOneByOneRubiksCubeMovements\OneByOneByOneRubiksCubeMovements
14+
* @group oneByOneByOneRubiksCubeMovements
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new OneByOneByOneRubiksCubeMovements();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "One rotation".
26+
*
27+
* @group oneByOneByOneRubiksCubeMovements_oneRotation
28+
*/
29+
public function testCanExecuteOneRotation(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - one rotation.txt',
33+
file_get_contents(__DIR__ . '/output/01 - one rotation.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Two rotations".
39+
*
40+
* @group oneByOneByOneRubiksCubeMovements_twoRotations
41+
*/
42+
public function testCanExecuteTwoRotations(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - two rotations.txt',
46+
file_get_contents(__DIR__ . '/output/02 - two rotations.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Give me five!".
52+
*
53+
* @group oneByOneByOneRubiksCubeMovements_giveMeFive
54+
*/
55+
public function testCanExecuteGiveMeFive(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - give me five.txt',
59+
file_get_contents(__DIR__ . '/output/03 - give me five.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Identity".
65+
*
66+
* @group oneByOneByOneRubiksCubeMovements_identity
67+
*/
68+
public function testCanExecuteIdentity(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - identity.txt',
72+
file_get_contents(__DIR__ . '/output/04 - identity.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "A long route".
78+
*
79+
* @group oneByOneByOneRubiksCubeMovements_aLongRoute
80+
*/
81+
public function testCanExecuteALongRoute(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - a long route.txt',
85+
file_get_contents(__DIR__ . '/output/05 - a long route.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Stuttering".
91+
*
92+
* @group oneByOneByOneRubiksCubeMovements_stuttering
93+
*/
94+
public function testCanExecuteStuttering(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - stuttering.txt',
98+
file_get_contents(__DIR__ . '/output/06 - stuttering.txt')
99+
);
100+
}
101+
}
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)