Skip to content

Commit 0d9d3b2

Browse files
committed
Adding tests for "Folding a note".
1 parent a7d0db4 commit 0d9d3b2

File tree

9 files changed

+153
-0
lines changed

9 files changed

+153
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- Tests for "Frog exchange".
3636
- Tests for "Fair numbering".
3737
- Tests for "A coin guessing game".
38+
- Tests for "Folding a note".
3839

3940
## [3.11.0] - 2022-07-31
4041
### 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\Medium\FoldingANote;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Folding a note" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/folding-a-note
12+
*/
13+
class FoldingANote implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $N);
18+
for ($i = 0; $i < $N; $i++)
19+
{
20+
$L = stream_get_line($stdin, $N + 1, "\n");
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("decoded note\n");
26+
}
27+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\FoldingANote;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\FoldingANote\FoldingANote;
9+
10+
/**
11+
* Tests for the "Folding a note" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\FoldingANote\FoldingANote
14+
* @group foldingANote
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new FoldingANote();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Easy".
26+
*
27+
* @group foldingANote_easy
28+
*/
29+
public function testCanExecuteEasy(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - easy.txt',
33+
"A" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "LOL".
39+
*
40+
* @group foldingANote_LOL
41+
*/
42+
public function testCanExecuteLOL(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - LOL.txt',
46+
"LMAO" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Brooo...".
52+
*
53+
* @group foldingANote_brooo...
54+
*/
55+
public function testCanExecuteBrooo(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - brooo....txt',
59+
"Duuuuuuuuuuuude!" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Piggy".
65+
*
66+
* @group foldingANote_piggy
67+
*/
68+
public function testCanExecutePiggy(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - piggy.txt',
72+
"The supervisor looks like a hog! Oink oink... I want some bacon." . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "I really like detention.".
78+
*
79+
* @group foldingANote_iReallyLikeDetention
80+
*/
81+
public function testCanExecuteIReallyLikeDetention(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - i really like detention.txt',
85+
file_get_contents(__DIR__ . '/output/05 - i really like detention.txt')
86+
);
87+
}
88+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
A
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
OA
3+
LM
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
uDuu
3+
u!eu
4+
uudu
5+
uuuu
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
krloo vi
3+
nmw Iaok
4+
ie. On o
5+
eeT!ghp
6+
s hoeua
7+
kacniob
8+
. t. ns.
9+
soskril
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
16
2+
onssoe rnynmw
3+
i c i f eodnsres
4+
lis .eann ,a ke
5+
sfwienw irt uae
6+
I rhaAp w eoet
7+
lomr. ahsyta t
8+
xb shifrmocwpsle
9+
foo ekognsi eui
10+
ps,eh erisltslss
11+
fswt, so h oai
12+
elaI pu cop. hsh
13+
ckne oeihnwhldah
14+
j m syoytehylhn
15+
f aon m diIelmee
16+
etahtt ncre ieht
17+
gfreti nimt eeos
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy.

0 commit comments

Comments
 (0)