Skip to content

Commit 7593100

Browse files
committed
Adding tests for "2×2×2 rubik’s cube
movements".
1 parent 2d345b6 commit 7593100

File tree

11 files changed

+111
-0
lines changed

11 files changed

+111
-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
## [3.16.0] - 2022-12-31
3536
### Added
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\TwoByTwoByTwoRubiksCubeMovements;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "2×2×2 rubik’s cube movements" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/222-rubiks-cube-movements
12+
*/
13+
class TwoByTwoByTwoRubiksCubeMovements implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%s", $move);
18+
19+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
20+
21+
echo("answer\n");
22+
}
23+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\TwoByTwoByTwoRubiksCubeMovements;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\TwoByTwoByTwoRubiksCubeMovements\TwoByTwoByTwoRubiksCubeMovements;
9+
10+
/**
11+
* Tests for the "2×2×2 rubik’s cube movements" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\TwoByTwoByTwoRubiksCubeMovements\TwoByTwoByTwoRubiksCubeMovements
14+
* @group twoByTwoByTwoRubiksCubeMovements
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new TwoByTwoByTwoRubiksCubeMovements();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Simple move".
26+
*
27+
* @group twoByTwoByTwoRubiksCubeMovements_simpleMove
28+
*/
29+
public function testCanExecuteSimpleMove(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - simple move.txt',
33+
file_get_contents(__DIR__ . '/output/01 - simple move.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Reverse move".
39+
*
40+
* @group twoByTwoByTwoRubiksCubeMovements_reverseMove
41+
*/
42+
public function testCanExecuteReverseMove(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - reverse move.txt',
46+
file_get_contents(__DIR__ . '/output/02 - reverse move.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Square move".
52+
*
53+
* @group twoByTwoByTwoRubiksCubeMovements_squareMove
54+
*/
55+
public function testCanExecuteSquareMove(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - square move.txt',
59+
file_get_contents(__DIR__ . '/output/03 - square move.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Classical algorithms".
65+
*
66+
* @group twoByTwoByTwoRubiksCubeMovements_classicalAlgorithms
67+
*/
68+
public function testCanExecuteClassicalAlgorithms(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - classical algorithms.txt',
72+
file_get_contents(__DIR__ . '/output/04 - classical algorithms.txt')
73+
);
74+
}
75+
}
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)