Skip to content

Commit 8faec20

Browse files
committed
Adding tests for "Super computer".
1 parent 42b6232 commit 8faec20

File tree

6 files changed

+100100
-1
lines changed

6 files changed

+100100
-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+
## [2.5.0] - 2022-02-13
88
### Added
99
- Tests for "Genome sequencing".
10+
- Tests for "Super computer".
1011

1112
## [2.4.0] - 2022-02-11
1213
### 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\SuperComputer;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Super computer" puzzle.
11+
*/
12+
class SuperComputer 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", $J, $D);
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("answer\n");
25+
}
26+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Training\Hard\SuperComputer;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Hard\SuperComputer\SuperComputer;
9+
10+
/**
11+
* Tests for the "Super computer" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Hard\SuperComputer\SuperComputer
14+
* @group superComputer
15+
*/
16+
final class SuperComputerTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new SuperComputer();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "Example 1".
25+
*
26+
* @group superComputer_example1
27+
*/
28+
public function testCanExecuteExample1(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - example 1.txt',
32+
3 . PHP_EOL
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "Example 2".
38+
*
39+
* @group superComputer_example2
40+
*/
41+
public function testCanExecuteExample2(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - example 2.txt',
45+
4 . PHP_EOL
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "Large number of scientists".
51+
*
52+
* @group superComputer_largeNumberOfScientists
53+
*/
54+
public function testCanExecuteLargeNumberOfScientists(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - large number of scientists.txt',
58+
7879 . PHP_EOL
59+
);
60+
}
61+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
2 5
3+
9 7
4+
15 6
5+
9 3
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
3 5
3+
9 2
4+
24 5
5+
16 9
6+
11 6

0 commit comments

Comments
 (0)