Skip to content

Commit ad73968

Browse files
committed
Adding tests for "Morellet’s random lines".
1 parent e24e0d5 commit ad73968

File tree

11 files changed

+390
-0
lines changed

11 files changed

+390
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Tests for "Auto pickup".
2929
- Tests for "Annihilation".
3030
- Tests for "Faro shuffle".
31+
- Tests for "Morellet’s random lines".
3132

3233
## [3.9.0] - 2022-06-01
3334
### Added
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\MorelletsRandomLines;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Morellet’s random lines" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/morellets-random-lines
12+
*/
13+
class MorelletsRandomLines implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d %d %d", $xA, $yA, $xB, $yB);
18+
fscanf($stdin, "%d", $n);
19+
for ($i = 0; $i < $n; $i++)
20+
{
21+
fscanf($stdin, "%d %d %d", $a, $b, $c);
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("YES|NO|ON A LINE\n");
27+
}
28+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\MorelletsRandomLines;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\MorelletsRandomLines\MorelletsRandomLines;
9+
10+
/**
11+
* Tests for the "Morellet’s random lines" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\MorelletsRandomLines\MorelletsRandomLines
14+
* @group morelletsRandomLines
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new MorelletsRandomLines();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "One line".
26+
*
27+
* @group morelletsRandomLines_oneLine
28+
*/
29+
public function testCanExecuteOneLine(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - one line.txt',
33+
"YES" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Two lines".
39+
*
40+
* @group morelletsRandomLines_twoLines
41+
*/
42+
public function testCanExecuteTwoLines(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - two lines.txt',
46+
"YES" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "On a line".
52+
*
53+
* @group morelletsRandomLines_onALine
54+
*/
55+
public function testCanExecuteOnALine(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - on a line.txt',
59+
"ON A LINE" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Many lines".
65+
*
66+
* @group morelletsRandomLines_manyLines
67+
*/
68+
public function testCanExecuteManyLines(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - many lines.txt',
72+
"NO" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Same line".
78+
*
79+
* @group morelletsRandomLines_sameLine
80+
*/
81+
public function testCanExecuteSameLine(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - same line.txt',
85+
"YES" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Lots of lines".
91+
*
92+
* @group morelletsRandomLines_lotsOfLines
93+
*/
94+
public function testCanExecuteLotsOfLines(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - lots of lines.txt',
98+
"ON A LINE" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Lots of lines 2".
104+
*
105+
* @group morelletsRandomLines_lotsOfLines2
106+
*/
107+
public function testCanExecuteLotsOfLines2(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - lots of lines 2.txt',
111+
"NO" . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Mind the sign".
117+
*
118+
* @group morelletsRandomLines_mindTheSign
119+
*/
120+
public function testCanExecuteMindTheSign(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - mind the sign.txt',
124+
"NO" . PHP_EOL
125+
);
126+
}
127+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1 1 0 0
2+
1
3+
1 2 3
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3 2 -2 -2
2+
2
3+
1 2 3
4+
1 1 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-1 0 -2 0
2+
1
3+
1 1 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-5 3 4 2
2+
10
3+
-7 6 -9
4+
-6 10 -7
5+
-3 -4 -2
6+
-3 1 0
7+
-3 8 3
8+
1 -5 -4
9+
3 -8 10
10+
3 9 -5
11+
8 3 -2
12+
10 4 -3
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3 2 -3 1
2+
2
3+
1 2 3
4+
2 4 6
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
7 -7 5 -5
2+
100
3+
-3 5 3
4+
9 -2 10
5+
-8 -5 3
6+
7 10 -5
7+
2 -4 1
8+
-6 9 5
9+
-3 6 9
10+
2 -6 -6
11+
-4 -2 -5
12+
0 1 3
13+
5 7 10
14+
8 2 -6
15+
3 4 1
16+
-10 5 -2
17+
1 6 -9
18+
3 0 3
19+
-6 -6 -1
20+
8 7 6
21+
-9 -9 9
22+
-7 7 -6
23+
9 -10 5
24+
0 5 2
25+
-4 -1 7
26+
2 2 -5
27+
-6 -4 4
28+
0 9 -7
29+
2 -7 10
30+
10 -6 -8
31+
-5 -9 4
32+
7 -6 0
33+
-5 -2 5
34+
-4 -9 -9
35+
4 -10 1
36+
7 7 10
37+
7 -6 1
38+
1 4 2
39+
-9 -4 3
40+
-1 0 -1
41+
-5 6 -10
42+
-10 -2 6
43+
-3 10 9
44+
6 5 5
45+
-2 -7 -4
46+
-6 3 1
47+
9 -3 1
48+
8 -6 2
49+
10 -8 5
50+
7 6 5
51+
-10 -2 -8
52+
9 -7 -7
53+
7 -1 -6
54+
9 10 -2
55+
-1 6 -6
56+
-5 -10 -10
57+
0 3 -7
58+
-9 8 -9
59+
7 -8 -4
60+
-7 5 -3
61+
9 -2 10
62+
-10 -9 2
63+
4 -3 -7
64+
2 10 8
65+
9 5 4
66+
9 0 9
67+
-10 10 0
68+
8 8 10
69+
0 -5 -1
70+
5 -1 2
71+
5 3 1
72+
3 10 8
73+
10 6 -4
74+
8 -9 0
75+
6 2 5
76+
9 4 6
77+
-8 7 -8
78+
5 -3 -3
79+
-1 -6 -9
80+
-9 -1 5
81+
-1 -3 -8
82+
-4 -8 -2
83+
5 8 10
84+
5 10 -9
85+
10 4 -9
86+
-7 -7 -2
87+
7 7 -4
88+
10 7 7
89+
7 4 -1
90+
-9 7 5
91+
8 0 -4
92+
0 -10 3
93+
7 6 4
94+
2 8 -9
95+
-5 3 -3
96+
10 -4 -1
97+
1 10 -4
98+
-8 -9 7
99+
5 -8 -7
100+
-8 4 -2
101+
-5 0 5
102+
7 -3 -4

0 commit comments

Comments
 (0)