Skip to content

Commit e217634

Browse files
committed
Adding tests for "Blowing fuse".
1 parent 7f35b4a commit e217634

File tree

13 files changed

+162
-1
lines changed

13 files changed

+162
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [3.4.0] - 2022-02-21
88
### Added
99
- Tests for "1D bush fire".
10+
- Tests for "Blowing fuse".
1011

1112
### Changed
1213
- "@medium" group to enforce time limit.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\BlowingFuse;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Blowing fuse" puzzle.
11+
*/
12+
class BlowingFuse implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d %d %d", $n, $m, $c);
17+
$inputs = explode(" ", fgets($stdin));
18+
for ($i = 0; $i < $n; $i++)
19+
{
20+
$nx = intval($inputs[$i]);
21+
}
22+
$inputs = explode(" ", fgets($stdin));
23+
for ($i = 0; $i < $m; $i++)
24+
{
25+
$mx = intval($inputs[$i]);
26+
}
27+
28+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
29+
30+
echo("Fuse was not blown.\n");
31+
echo("Maximal consumed current was XX A.\n");
32+
}
33+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\BlowingFuse;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\BlowingFuse\BlowingFuse;
9+
10+
/**
11+
* Tests for the "Blowing fuse" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\BlowingFuse\BlowingFuse
14+
* @group blowingFuse
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new BlowingFuse();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Blown".
26+
*
27+
* @group blowingFuse_blown
28+
*/
29+
public function testCanExecuteBlown(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - blown.txt',
33+
'Fuse was blown.' . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Not blown".
39+
*
40+
* @group blowingFuse_notBlown
41+
*/
42+
public function testCanExecuteNotBlown(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - not blown.txt',
46+
file_get_contents(__DIR__ . '/output/02 - not blown.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Single device".
52+
*
53+
* @group blowingFuse_singleDevice
54+
*/
55+
public function testCanExecuteSingleDevice(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - single device.txt',
59+
'Fuse was blown.' . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "More device".
65+
*
66+
* @group blowingFuse_moreDevice
67+
*/
68+
public function testCanExecuteMoreDevice(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - more device.txt',
72+
file_get_contents(__DIR__ . '/output/04 - more device.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "More clicks, more devices".
78+
*
79+
* @group blowingFuse_moreClicksMoreDevice
80+
*/
81+
public function testCanExecuteMoreClicksMoreDevice(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - more clicks, more devices.txt',
85+
file_get_contents(__DIR__ . '/output/05 - more clicks, more devices.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Power hungry".
91+
*
92+
* @group blowingFuse_powerHungry
93+
*/
94+
public function testCanExecutePowerHungry(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - power hungry.txt',
98+
file_get_contents(__DIR__ . '/output/06 - power hungry.txt')
99+
);
100+
}
101+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
5 2 10
2+
11 6 11 10 10
3+
3 3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
5 8 82
2+
18 20 3 1 20
3+
2 4 3 3 5 4 2 3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1 10 1
2+
9
3+
1 1 1 1 1 1 1 1 1 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
6 24 71
2+
10 10 14 14 14 15
3+
4 3 3 5 4 1 5 5 5 4 1 5 5 4 2 3 3 3 1 6 2 1 5 5
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
11 20 72
2+
11 10 13 19 15 9 20 10 16 12 5
3+
6 8 3 4 8 6 10 3 6 5 2 4 10 2 6 6 4 2 4 5
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
20 20 200
2+
3 12 5 8 15 12 12 10 11 16 10 19 17 15 11 9 17 6 14 5
3+
1 3 5 7 5 9 2 4 6 8 10 11 13 15 2 17 12 14 16 18
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fuse was not blown.
2+
Maximal consumed current was 41 A.

0 commit comments

Comments
 (0)