Skip to content

Commit de493d7

Browse files
committed
Adding tests for "Blunder - episode 3".
1 parent 49f892d commit de493d7

File tree

11 files changed

+1677
-0
lines changed

11 files changed

+1677
-0
lines changed

CHANGELOG.md

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

1213
## [2.5.0] - 2022-02-13
1314
### Added
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Training\Hard\BlunderEpisode3;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Blunder - episode 3" puzzle.
11+
*/
12+
class BlunderEpisode3 implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d", $N);
17+
for ($i = 0; $i < $N; $i++)
18+
{
19+
fscanf($stdin, "%d %d", $num, $t);
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("answer\n");
25+
}
26+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Training\Hard\BlunderEpisode3;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Hard\BlunderEpisode3\BlunderEpisode3;
9+
10+
/**
11+
* Tests for the "Blunder - episode 3" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Hard\BlunderEpisode3\BlunderEpisode3
14+
* @group blunderEpisode3
15+
*/
16+
final class BlunderEpisode3Test extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new BlunderEpisode3();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "O(1)".
25+
*
26+
* @group blunderEpisode3_O1
27+
*/
28+
public function testCanExecuteO1(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - O(1).txt',
32+
'O(1)' . PHP_EOL
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "O(log n)".
38+
*
39+
* @group blunderEpisode3_OLogN
40+
*/
41+
public function testCanExecuteOLogN(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - O(log n).txt',
45+
'O(log n)' . PHP_EOL
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "O(n)".
51+
*
52+
* @group blunderEpisode3_ON
53+
*/
54+
public function testCanExecuteON(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - O(n).txt',
58+
'O(n)' . PHP_EOL
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "O(n log n)".
64+
*
65+
* @group blunderEpisode3_ONLogN
66+
*/
67+
public function testCanExecuteONLogN(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - O(n log n).txt',
71+
'O(n log n)' . PHP_EOL
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "O(n^2)".
77+
*
78+
* @group blunderEpisode3_ON2
79+
*/
80+
public function testCanExecuteON2(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - O(n^2).txt',
84+
'O(n^2)' . PHP_EOL
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "O(n^2 log n)".
90+
*
91+
* @group blunderEpisode3_ON2LogN
92+
*/
93+
public function testCanExecuteON2LogN(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - O(n^2 log n).txt',
97+
'O(n^2 log n)' . PHP_EOL
98+
);
99+
}
100+
101+
/**
102+
* Test that the code can be executed for "O(n^3)".
103+
*
104+
* @group blunderEpisode3_ON3
105+
*/
106+
public function testCanExecuteON3(): void
107+
{
108+
$this->expectExecuteOutputAnswer(
109+
__DIR__ . '/input/07 - O(n^3).txt',
110+
'O(n^3)' . PHP_EOL
111+
);
112+
}
113+
114+
/**
115+
* Test that the code can be executed for "O(2^n)".
116+
*
117+
* @group blunderEpisode3_O2N
118+
*/
119+
public function testCanExecuteO2N(): void
120+
{
121+
$this->expectExecuteOutputAnswer(
122+
__DIR__ . '/input/08 - O(2^n).txt',
123+
'O(2^n)' . PHP_EOL
124+
);
125+
}
126+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
100
2+
10 200000
3+
110 180000
4+
210 190000
5+
310 180000
6+
410 190000
7+
510 180000
8+
610 190000
9+
710 190000
10+
810 180000
11+
910 190000
12+
1010 180000
13+
1110 190000
14+
1210 190000
15+
1310 180000
16+
1410 190000
17+
1510 190000
18+
1610 180000
19+
1710 190000
20+
1810 180000
21+
1910 190000
22+
2010 190000
23+
2110 180000
24+
2210 190000
25+
2310 190000
26+
2410 180000
27+
2510 190000
28+
2610 190000
29+
2710 180000
30+
2810 190000
31+
2910 180000
32+
3010 190000
33+
3110 180000
34+
3210 190000
35+
3310 190000
36+
3410 180000
37+
3510 190000
38+
3610 180000
39+
3710 180000
40+
3810 190000
41+
3910 180000
42+
4010 190000
43+
4110 190000
44+
4210 180000
45+
4310 180000
46+
4410 180000
47+
4510 190000
48+
4610 190000
49+
4710 180000
50+
4810 190000
51+
4910 190000
52+
5010 180000
53+
5110 190000
54+
5210 180000
55+
5310 190000
56+
5410 180000
57+
5510 190000
58+
5610 190000
59+
5710 180000
60+
5810 190000
61+
5910 190000
62+
6010 180000
63+
6110 190000
64+
6210 190000
65+
6310 180000
66+
6410 190000
67+
6510 180000
68+
6610 190000
69+
6710 190000
70+
6810 180000
71+
6910 180000
72+
7010 190000
73+
7110 190000
74+
7210 180000
75+
7310 190000
76+
7410 190000
77+
7510 180000
78+
7610 180000
79+
7710 180000
80+
7810 190000
81+
7910 190000
82+
8010 180000
83+
8110 190000
84+
8210 190000
85+
8310 190000
86+
8410 190000
87+
8510 180000
88+
8610 190000
89+
8710 190000
90+
8810 190000
91+
8910 190000
92+
9010 180000
93+
9110 180000
94+
9210 190000
95+
9310 190000
96+
9410 190000
97+
9510 180000
98+
9610 180000
99+
9710 180000
100+
9810 190000
101+
9910 190000

0 commit comments

Comments
 (0)