Skip to content

Commit b02c4e1

Browse files
committed
Adding tests for "Hooch clash".
1 parent a1c7c1e commit b02c4e1

File tree

14 files changed

+213
-0
lines changed

14 files changed

+213
-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 "How time flies".
3333
- Tests for "Minesweeper level generator".
3434
- Tests for "In stereo".
35+
- Tests for "Hooch clash".
3536

3637
### Changed
3738
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\HoochClash;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Hooch clash" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/hooch-clash
12+
*/
13+
class HoochClash implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d", $orbSizeMin, $orbSizeMax);
18+
fscanf($stdin, "%d %d", $glowingSize1, $glowingSize2);
19+
20+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
21+
22+
echo("VALID\n");
23+
}
24+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\HoochClash;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\HoochClash\HoochClash;
9+
10+
/**
11+
* Tests for the "Hooch clash" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\HoochClash\HoochClash
14+
* @group hoochClash
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new HoochClash();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "This is fun!".
26+
*
27+
* @group hoochClash_thisIsFun
28+
*/
29+
public function testCanExecuteThisIsFun(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - this is fun!.txt',
33+
"1 12" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "This is valid!".
39+
*
40+
* @group hoochClash_thisIsValid
41+
*/
42+
public function testCanExecuteThisIsValid(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - this is valid!.txt',
46+
"VALID" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Fun enough".
52+
*
53+
* @group hoochClash_funEnough
54+
*/
55+
public function testCanExecuteFunEnough(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - fun enough.txt',
59+
"11 493" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Whee".
65+
*
66+
* @group hoochClash_whee
67+
*/
68+
public function testCanExecuteWhee(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - whee.txt',
72+
"22 986" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Higher".
78+
*
79+
* @group hoochClash_higher
80+
*/
81+
public function testCanExecuteHigher(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - higher.txt',
85+
"VALID" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Much higher".
91+
*
92+
* @group hoochClash_muchHigher
93+
*/
94+
public function testCanExecuteMuchHigher(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - much higher.txt',
98+
"1200 2680" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Crazy high".
104+
*
105+
* @group hoochClash_crazyHigh
106+
*/
107+
public function testCanExecuteCrazyHigh(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - crazy high.txt',
111+
"2719 2790" . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Stoned".
117+
*
118+
* @group hoochClash_stoned
119+
*/
120+
public function testCanExecuteStoned(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - stoned.txt',
124+
"1290 2881" . PHP_EOL
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "Overflow".
130+
*
131+
* @group hoochClash_overflow
132+
*/
133+
public function testCanExecuteOverflow(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - overflow.txt',
137+
"VALID" . PHP_EOL
138+
);
139+
}
140+
141+
/**
142+
* Test that the code can be executed for "Underflow".
143+
*
144+
* @group hoochClash_underflow
145+
*/
146+
public function testCanExecuteUnderflow(): void
147+
{
148+
$this->expectExecuteOutputAnswer(
149+
__DIR__ . '/input/10 - underflow.txt',
150+
"VALID" . PHP_EOL
151+
);
152+
}
153+
154+
/**
155+
* Test that the code can be executed for "B&B".
156+
*
157+
* @group hoochClash_BB
158+
*/
159+
public function testCanExecuteBB(): void
160+
{
161+
$this->expectExecuteOutputAnswer(
162+
__DIR__ . '/input/11 - B&B.txt',
163+
"VALID" . PHP_EOL
164+
);
165+
}
166+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 1000
2+
9 10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 1000
2+
5 7
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 1000
2+
90 492
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 1000
2+
180 984
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1000 2000
2+
1002 1003
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1000 3000
2+
1356 2644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1000 3000
2+
2511 2962

0 commit comments

Comments
 (0)