Skip to content

Commit 3244070

Browse files
committed
Adding tests for "Distributing candy".
1 parent 8666c77 commit 3244070

File tree

8 files changed

+126
-0
lines changed

8 files changed

+126
-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 "A mountain of a mole hill".
3636
- Tests for "Where's Wally".
3737
- Tests for "Feature extraction".
38+
- Tests for "Distributing candy".
3839

3940
## [3.7.0] - 2022-03-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\Easy\DistributingCandy;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Distributing candy" puzzle.
11+
*/
12+
class DistributingCandy implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d %d", $n, $m);
17+
$inputs = explode(" ", fgets($stdin));
18+
for ($i = 0; $i < $n; $i++)
19+
{
20+
$x = intval($inputs[$i]);
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("answer\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\Easy\DistributingCandy;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\DistributingCandy\DistributingCandy;
9+
10+
/**
11+
* Tests for the "Distributing candy" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\DistributingCandy\DistributingCandy
14+
* @group distributingCandy
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new DistributingCandy();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Test 1".
26+
*
27+
* @group distributingCandy_test1
28+
*/
29+
public function testCanExecuteTest1(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - test 1.txt',
33+
2 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Test 2".
39+
*
40+
* @group distributingCandy_test2
41+
*/
42+
public function testCanExecuteTest2(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - test 2.txt',
46+
5 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Test 3".
52+
*
53+
* @group distributingCandy_test3
54+
*/
55+
public function testCanExecuteTest3(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - test 3.txt',
59+
23 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Test 4".
65+
*
66+
* @group distributingCandy_test4
67+
*/
68+
public function testCanExecuteTest4(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - test 4.txt',
72+
13 . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Test 5".
78+
*
79+
* @group distributingCandy_test5
80+
*/
81+
public function testCanExecuteTest5(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - test 5.txt',
85+
20 . PHP_EOL
86+
);
87+
}
88+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
6 3
2+
7 1 3 10 12 10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
26 5
2+
0 0 16 61 22 26 58 38 61 68 2 59 3 23 67 68 33 90 27 35 49 97 8 97 10 25
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
72 21
2+
0 1 19 31 36 23 6 35 11 73 38 4 22 70 16 49 31 87 62 91 61 72 47 53 4 21 67 65 77 34 60 27 96 59 9 70 13 29 79 32 81 47 30 82 87 93 10 89 97 21 17 68 55 14 82 69 46 85 7 28 66 87 49 97 81 0 58 90 3 35 96 20
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
240 41
2+
0 5 42 25 30 62 20 78 29 35 73 87 38 3 23 94 92 9 94 35 45 1 11 66 47 19 2 41 93 60 16 99 39 79 59 65 65 42 58 71 73 56 36 70 99 32 8 51 79 6 28 58 9 8 42 5 26 31 43 8 31 45 91 37 45 36 23 92 2 76 14 56 67 35 75 77 89 56 13 49 83 73 40 64 97 38 54 76 0 82 51 0 30 20 54 95 4 94 37 16 10 29 13 9 22 55 67 35 95 67 59 91 91 28 61 97 8 12 85 40 58 91 88 21 85 96 77 12 25 60 49 18 2 87 16 65 81 29 41 71 35 96 23 86 49 2 35 80 31 96 73 29 78 57 0 61 58 72 62 6 49 38 34 25 70 35 25 84 44 55 42 1 28 2 15 77 34 77 40 79 26 26 38 33 78 5 67 27 97 60 97 67 70 31 10 46 53 10 65 6 81 72 21 63 98 90 19 73 98 38 94 11 4 76 83 33 0 55 17 73 18 9 69 20 46 62 93 62 40 69 55 26 82 97 76 33 45 55 83 16
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
192 51
2+
0 1 53 98 15 96 37 5 48 90 14 1 48 98 32 9 59 21 35 53 34 16 92 41 64 8 15 12 57 19 32 63 76 33 44 90 67 70 11 51 72 73 98 50 80 20 7 69 67 81 88 9 19 70 50 72 37 50 36 66 27 32 50 96 74 78 32 20 91 28 72 62 23 43 13 19 84 16 57 78 37 30 91 59 34 48 1 4 64 31 29 87 66 74 72 81 32 99 64 80 34 15 4 71 70 77 19 68 55 32 89 56 48 44 77 58 18 83 79 76 49 46 62 61 98 16 23 62 83 27 25 68 9 21 77 46 33 96 80 45 25 64 89 34 85 70 83 30 5 1 0 66 60 53 26 58 82 13 82 89 1 14 21 54 76 53 26 24 48 88 85 35 64 84 84 98 64 63 8 95 2 49 75 74 56 83 62 63 33 51 48 16

0 commit comments

Comments
 (0)