Skip to content

Commit 3207eba

Browse files
committed
Adding tests for "Smooth!".
1 parent 995f84e commit 3207eba

File tree

11 files changed

+227
-0
lines changed

11 files changed

+227
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Tests for "Decode the message".
3333
- Tests for "Detective geek".
3434
- Tests for "Largest number".
35+
- Tests for "Smooth!".
3536

3637
## [3.9.0] - 2022-06-01
3738
### Added
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\Smooth;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Smooth!" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/smooth
12+
*/
13+
class Smooth implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $N);
18+
for ($i = 0; $i < $N; $i++)
19+
{
20+
fscanf($stdin, "%d", $F);
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("DEFEAT\n");
26+
}
27+
}
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\Easy\Smooth;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\Smooth\Smooth;
9+
10+
/**
11+
* Tests for the "Smooth!" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\Smooth\Smooth
14+
* @group smooth
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new Smooth();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Small bulk".
26+
*
27+
* @group smooth_smallBulk
28+
*/
29+
public function testCanExecuteSmallBulk(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - small bulk.txt',
33+
file_get_contents(__DIR__ . '/output/01 - small bulk.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Easy victories".
39+
*
40+
* @group smooth_easyVictories
41+
*/
42+
public function testCanExecuteEasyVictories(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - easy victories.txt',
46+
file_get_contents(__DIR__ . '/output/02 - easy victories.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Easy defeats".
52+
*
53+
* @group smooth_easyDefeats
54+
*/
55+
public function testCanExecuteEasyDefeats(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - easy defeats.txt',
59+
file_get_contents(__DIR__ . '/output/03 - easy defeats.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Bigger".
65+
*
66+
* @group smooth_bigger
67+
*/
68+
public function testCanExecuteBigger(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - bigger.txt',
72+
file_get_contents(__DIR__ . '/output/04 - bigger.txt')
73+
);
74+
}
75+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
1
3+
2
4+
3
5+
4
6+
5
7+
6
8+
7
9+
8
10+
9
11+
10
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15
2+
600
3+
640
4+
675
5+
729
6+
768
7+
810
8+
900
9+
972
10+
1024
11+
1125
12+
1200
13+
1250
14+
1296
15+
1440
16+
1500
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15
2+
630
3+
650
4+
732
5+
760
6+
806
7+
872
8+
966
9+
1001
10+
1092
11+
1160
12+
1216
13+
1290
14+
1400
15+
1460
16+
1539
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
20
2+
8916100448256000
3+
8905786697765618
4+
8978233254014990
5+
8883664392439636
6+
8967378984372715
7+
8906044184985600
8+
8815968460800000
9+
8839938372534426
10+
8887458428319767
11+
8847360000000000
12+
8957952000000000
13+
8898925781250000
14+
8968066875000000
15+
8926168066560000
16+
8857350000000000
17+
8981943434664571
18+
8855835700998201
19+
8910737505679793
20+
8825923015031250
21+
8983733062992534
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
VICTORY
2+
VICTORY
3+
VICTORY
4+
VICTORY
5+
VICTORY
6+
VICTORY
7+
DEFEAT
8+
VICTORY
9+
VICTORY
10+
VICTORY
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
VICTORY
2+
VICTORY
3+
VICTORY
4+
VICTORY
5+
VICTORY
6+
VICTORY
7+
VICTORY
8+
VICTORY
9+
VICTORY
10+
VICTORY
11+
VICTORY
12+
VICTORY
13+
VICTORY
14+
VICTORY
15+
VICTORY
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
DEFEAT
2+
DEFEAT
3+
DEFEAT
4+
DEFEAT
5+
DEFEAT
6+
DEFEAT
7+
DEFEAT
8+
DEFEAT
9+
DEFEAT
10+
DEFEAT
11+
DEFEAT
12+
DEFEAT
13+
DEFEAT
14+
DEFEAT
15+
DEFEAT

0 commit comments

Comments
 (0)