Skip to content

Commit e76be64

Browse files
committed
Adding tests for "Winamax".
1 parent de493d7 commit e76be64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+652
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Tests for "Roller coaster".
1010
- Tests for "TAN network".
1111
- Tests for "Blunder - episode 3".
12+
- Tests for "Winamax".
1213

1314
## [2.5.0] - 2022-02-13
1415
### Added
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Training\Hard\Winamax;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Winamax" puzzle.
11+
*/
12+
class Winamax implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d %d", $width, $height);
17+
for ($i = 0; $i < $height; $i++)
18+
{
19+
fscanf($stdin, "%s", $row);
20+
}
21+
}
22+
}
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Training\Hard\Winamax;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Hard\Winamax\Winamax;
9+
10+
/**
11+
* Tests for the "Winamax" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Hard\Winamax\Winamax
14+
* @group winamax
15+
*/
16+
final class WinamaxTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new Winamax();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "Test 1".
25+
*
26+
* @group winamax_test1
27+
*/
28+
public function testCanExecuteTest1(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - test 1.txt',
32+
'>.' . PHP_EOL
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "Test 2".
38+
*
39+
* @group winamax_test2
40+
*/
41+
public function testCanExecuteTest2(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - test 2.txt',
45+
file_get_contents(__DIR__ . '/output/02 - test 2.txt')
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "Test 3".
51+
*
52+
* @group winamax_test3
53+
*/
54+
public function testCanExecuteTest3(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - test 3.txt',
58+
file_get_contents(__DIR__ . '/output/03 - test 3.txt')
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "Test 4".
64+
*
65+
* @group winamax_test4
66+
*/
67+
public function testCanExecuteTest4(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - test 4.txt',
71+
file_get_contents(__DIR__ . '/output/04 - test 4.txt')
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "Test 5".
77+
*
78+
* @group winamax_test5
79+
*/
80+
public function testCanExecuteTest5(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - test 5.txt',
84+
file_get_contents(__DIR__ . '/output/05 - test 5.txt')
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "Test 6".
90+
*
91+
* @group winamax_test6
92+
*/
93+
public function testCanExecuteTest6(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - test 6.txt',
97+
file_get_contents(__DIR__ . '/output/06 - test 6.txt')
98+
);
99+
}
100+
101+
/**
102+
* Test that the code can be executed for "Test 7".
103+
*
104+
* @group winamax_test7
105+
*/
106+
public function testCanExecuteTest7(): void
107+
{
108+
$this->expectExecuteOutputAnswer(
109+
__DIR__ . '/input/07 - test 7.txt',
110+
file_get_contents(__DIR__ . '/output/07 - test 7.txt')
111+
);
112+
}
113+
114+
/**
115+
* Test that the code can be executed for "Test 8".
116+
*
117+
* @group winamax_test8
118+
*/
119+
public function testCanExecuteTest8(): void
120+
{
121+
$this->expectExecuteOutputAnswer(
122+
__DIR__ . '/input/08 - test 8.txt',
123+
file_get_contents(__DIR__ . '/output/08 - test 8.txt')
124+
);
125+
}
126+
127+
/**
128+
* Test that the code can be executed for "Test 9".
129+
*
130+
* @group winamax_test9
131+
*/
132+
public function testCanExecuteTest9(): void
133+
{
134+
$this->expectExecuteOutputAnswer(
135+
__DIR__ . '/input/09 - test 9.txt',
136+
file_get_contents(__DIR__ . '/output/09 - test 9.txt')
137+
);
138+
}
139+
140+
/**
141+
* Test that the code can be executed for "Test 10".
142+
*
143+
* @group winamax_test10
144+
*/
145+
public function testCanExecuteTest10(): void
146+
{
147+
$this->expectExecuteOutputAnswer(
148+
__DIR__ . '/input/10 - test 10.txt',
149+
file_get_contents(__DIR__ . '/output/10 - test 10.txt')
150+
);
151+
}
152+
153+
/**
154+
* Test that the code can be executed for "Test 11".
155+
*
156+
* @group winamax_test11
157+
*/
158+
public function testCanExecuteTest11(): void
159+
{
160+
$this->expectExecuteOutputAnswer(
161+
__DIR__ . '/input/11 - test 11.txt',
162+
file_get_contents(__DIR__ . '/output/11 - test 11.txt')
163+
);
164+
}
165+
166+
/**
167+
* Test that the code can be executed for "Test 12".
168+
*
169+
* @group winamax_test12
170+
*/
171+
public function testCanExecuteTest12(): void
172+
{
173+
$this->expectExecuteOutputAnswer(
174+
__DIR__ . '/input/12 - test 12.txt',
175+
file_get_contents(__DIR__ . '/output/12 - test 12.txt')
176+
);
177+
}
178+
179+
/**
180+
* Test that the code can be executed for "Test 13".
181+
*
182+
* @group winamax_test13
183+
*/
184+
public function testCanExecuteTest13(): void
185+
{
186+
$this->expectExecuteOutputAnswer(
187+
__DIR__ . '/input/13 - test 13.txt',
188+
file_get_contents(__DIR__ . '/output/13 - test 13.txt')
189+
);
190+
}
191+
192+
/**
193+
* Test that the code can be executed for "Test 14".
194+
*
195+
* @group winamax_test14
196+
*/
197+
public function testCanExecuteTest14(): void
198+
{
199+
$this->expectExecuteOutputAnswer(
200+
__DIR__ . '/input/14 - test 14.txt',
201+
file_get_contents(__DIR__ . '/output/14 - test 14.txt')
202+
);
203+
}
204+
205+
/**
206+
* Test that the code can be executed for "Test 15".
207+
*
208+
* @group winamax_test15
209+
*/
210+
public function testCanExecuteTest15(): void
211+
{
212+
$this->expectExecuteOutputAnswer(
213+
__DIR__ . '/input/15 - test 15.txt',
214+
file_get_contents(__DIR__ . '/output/15 - test 15.txt')
215+
);
216+
}
217+
218+
/**
219+
* Test that the code can be executed for "Test 16".
220+
*
221+
* @group winamax_test16
222+
*/
223+
public function testCanExecuteTest16(): void
224+
{
225+
$this->expectExecuteOutputAnswer(
226+
__DIR__ . '/input/16 - test 16.txt',
227+
file_get_contents(__DIR__ . '/output/16 - test 16.txt')
228+
);
229+
}
230+
231+
/**
232+
* Test that the code can be executed for "Test 17".
233+
*
234+
* @group winamax_test17
235+
*/
236+
public function testCanExecuteTest17(): void
237+
{
238+
$this->expectExecuteOutputAnswer(
239+
__DIR__ . '/input/17 - test 17.txt',
240+
file_get_contents(__DIR__ . '/output/17 - test 17.txt')
241+
);
242+
}
243+
244+
/**
245+
* Test that the code can be executed for "Test 18".
246+
*
247+
* @group winamax_test18
248+
*/
249+
public function testCanExecuteTest18(): void
250+
{
251+
$this->expectExecuteOutputAnswer(
252+
__DIR__ . '/input/18 - test 18.txt',
253+
file_get_contents(__DIR__ . '/output/18 - test 18.txt')
254+
);
255+
}
256+
257+
/**
258+
* Test that the code can be executed for "Test 19".
259+
*
260+
* @group winamax_test19
261+
*/
262+
public function testCanExecuteTest19(): void
263+
{
264+
$this->expectExecuteOutputAnswer(
265+
__DIR__ . '/input/19 - test 19.txt',
266+
file_get_contents(__DIR__ . '/output/19 - test 19.txt')
267+
);
268+
}
269+
270+
/**
271+
* Test that the code can be executed for "Test 20".
272+
*
273+
* @group winamax_test20
274+
*/
275+
public function testCanExecuteTest20(): void
276+
{
277+
$this->expectExecuteOutputAnswer(
278+
__DIR__ . '/input/20 - test 20.txt',
279+
file_get_contents(__DIR__ . '/output/20 - test 20.txt')
280+
);
281+
}
282+
283+
/**
284+
* Test that the code can be executed for "Test 21".
285+
*
286+
* @group winamax_test21
287+
*/
288+
public function testCanExecuteTest21(): void
289+
{
290+
$this->expectExecuteOutputAnswer(
291+
__DIR__ . '/input/21 - test 21.txt',
292+
file_get_contents(__DIR__ . '/output/21 - test 21.txt')
293+
);
294+
}
295+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2 1
2+
1H
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3 3
2+
2.X
3+
..H
4+
.H1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5 5
2+
4..XX
3+
.H.H.
4+
...H.
5+
.2..2
6+
.....
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
6 6
2+
3..H.2
3+
.2..H.
4+
..H..H
5+
.X.2.X
6+
......
7+
3..H..
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8 8
2+
.XXX.5X.
3+
X.4.X..X
4+
X4..X3.X
5+
X...X.X.
6+
.X.X.H.X
7+
X.HX...X
8+
X..X.H.X
9+
.XH.XXX.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8 8
2+
.......4
3+
....HH.2
4+
..5.....
5+
H....22X
6+
.3XH.HXX
7+
..X3.H.X
8+
..XH....
9+
H2X.H..3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8 8
2+
4H5.....
3+
......3.
4+
......H.
5+
.....H3.
6+
........
7+
....HH..
8+
.43.....
9+
..H3H...

0 commit comments

Comments
 (0)