Skip to content

Commit b3e9775

Browse files
committed
Adding tests for "Bijective numeration".
1 parent 1023f22 commit b3e9775

File tree

12 files changed

+187
-0
lines changed

12 files changed

+187
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Tests for "Solid integer".
3232
- Tests for "Bit count to limit".
3333
- Tests for "Porcupine fever".
34+
- Tests for "Bijective numeration".
3435

3536
### Fixed
3637
- Tests groups for "CGFunge interpreter".
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\Medium\BijectiveNumeration;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Bijective numeration" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/bijective-numeration
12+
*/
13+
class BijectiveNumeration implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $count);
18+
$inputs = explode(" ", fgets($stdin));
19+
for ($i = 0; $i < $count; $i++)
20+
{
21+
$decimary = ($inputs[$i]);
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("summation\n");
27+
}
28+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\BijectiveNumeration;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\BijectiveNumeration\BijectiveNumeration;
9+
10+
/**
11+
* Tests for the "Bijective numeration" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\BijectiveNumeration\BijectiveNumeration
14+
* @group bijectiveNumeration
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new BijectiveNumeration();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Simple parsing".
26+
*
27+
* @group bijectiveNumeration_simpleParsing
28+
*/
29+
public function testCanExecuteSimpleParsing(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - simple parsing.txt',
33+
"32" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Parsing".
39+
*
40+
* @group bijectiveNumeration_parsing
41+
*/
42+
public function testCanExecuteParsing(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - parsing.txt',
46+
"234" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "More parsing".
52+
*
53+
* @group bijectiveNumeration_moreParsing
54+
*/
55+
public function testCanExecuteMoreParsing(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - more parsing.txt',
59+
"2345" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Simple generation".
65+
*
66+
* @group bijectiveNumeration_simpleGeneration
67+
*/
68+
public function testCanExecuteSimpleGeneration(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - simple generation.txt',
72+
"A" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Generation".
78+
*
79+
* @group bijectiveNumeration_generation
80+
*/
81+
public function testCanExecuteGeneration(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - generation.txt',
85+
"A24" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "More generation".
91+
*
92+
* @group bijectiveNumeration_moreGeneration
93+
*/
94+
public function testCanExecuteMoreGeneration(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - more generation.txt',
98+
"AA" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Mixed test".
104+
*
105+
* @group bijectiveNumeration_mixedTest
106+
*/
107+
public function testCanExecuteMixedTest(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - mixed test.txt',
111+
"1AAA" . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Bigger test".
117+
*
118+
* @group bijectiveNumeration_biggerTest
119+
*/
120+
public function testCanExecuteBiggerTest(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - bigger test.txt',
124+
"9A3A" . PHP_EOL
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "Huge test".
130+
*
131+
* @group bijectiveNumeration_hugeTest
132+
*/
133+
public function testCanExecuteHugeTest(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - huge test.txt',
137+
"1344AA18A" . PHP_EOL
138+
);
139+
}
140+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
A A 12
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
9A A2 1A 12
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1AA A2A AA5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
1 2 3 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
8
2+
512 256 128 64 32 16 8 8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
19 91
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
99A 9A9 A1

0 commit comments

Comments
 (0)