Skip to content

Commit 42b6232

Browse files
committed
Adding tests for "Genome sequencing".
1 parent c50428d commit 42b6232

File tree

10 files changed

+166
-0
lines changed

10 files changed

+166
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +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]
8+
### Added
9+
- Tests for "Genome sequencing".
10+
711
## [2.4.0] - 2022-02-11
812
### Added
913
- Tests for "Blunder - episode 2".
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\GenomeSequencing;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Genome sequencing" puzzle.
11+
*/
12+
class GenomeSequencing 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, "%s", $subseq);
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("answer\n");
25+
}
26+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Training\Hard\GenomeSequencing;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Hard\GenomeSequencing\GenomeSequencing;
9+
10+
/**
11+
* Tests for the "Genome sequencing" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Hard\GenomeSequencing\GenomeSequencing
14+
* @group genomeSequencing
15+
*/
16+
final class GenomeSequencingTest extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new GenomeSequencing();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "AACCTT".
25+
*
26+
* @group surface_AACCTT
27+
*/
28+
public function testCanExecuteAACCTT(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - AACCTT.txt',
32+
6 . PHP_EOL
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "AGATTACAGA".
38+
*
39+
* @group surface_AGATTACAGA
40+
*/
41+
public function testCanExecuteAGATTACAGA(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - AGATTACAGA.txt',
45+
10 . PHP_EOL
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "AACTT".
51+
*
52+
* @group surface_AACTT
53+
*/
54+
public function testCanExecuteAACTT(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - AACTT.txt',
58+
5 . PHP_EOL
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "AGATTA".
64+
*
65+
* @group surface_AGATTA
66+
*/
67+
public function testCanExecuteAGATTA(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - AGATTA.txt',
71+
6 . PHP_EOL
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "Reversed AGATTA".
77+
*
78+
* @group surface_reversedAGATTA
79+
*/
80+
public function testCanExecuteReversedAGATTA(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - reversed AGATTA.txt',
84+
6 . PHP_EOL
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "ATCG".
90+
*
91+
* @group surface_ATCG
92+
*/
93+
public function testCanExecuteReversedATCG(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - ATCG.txt',
97+
4 . PHP_EOL
98+
);
99+
}
100+
101+
/**
102+
* Test that the code can be executed for "CCCTGACATGA".
103+
*
104+
* @group surface_CCCTGACATGA
105+
*/
106+
public function testCanExecuteCCCTGACATGA(): void
107+
{
108+
$this->expectExecuteOutputAnswer(
109+
__DIR__ . '/input/07 - CCCTGACATGA.txt',
110+
11 . PHP_EOL
111+
);
112+
}
113+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
AAC
3+
CCTT
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
AAC
3+
CCTT
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
TT
3+
AA
4+
ACT
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
AGATTA
3+
GAT
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
GAT
3+
AGATTA
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
AT
3+
CG
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
CCCTG
3+
TGACA
4+
CATGA

0 commit comments

Comments
 (0)