Skip to content

Commit 67c84e7

Browse files
committed
Adding tests for "Rearrange string to two
numbers".
1 parent 9d6eff9 commit 67c84e7

21 files changed

+300
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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.16.0] - 2022-12-31
88
### Added
99
- Tests for "Sticky keyboard".
1010
- Tests for "Bingo!".
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
- Tests for "DDCG mapper".
3737
- Tests for "Queneau numbers".
3838
- Tests for "Simple fraction to mixed number".
39+
- Tests for "Rearrange string to two numbers".
3940

4041
### Fixed
4142
- Tests groups for "CGFunge interpreter".
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\RearrangeStringToTwoNumbers;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Rearrange string to two numbers" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/rearrange-string-to-two-numbers
12+
*/
13+
class RearrangeStringToTwoNumbers implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
$S = stream_get_line($stdin, 50 + 1, "\n");
18+
19+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
20+
21+
echo("-1 -1\n");
22+
}
23+
}
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\RearrangeStringToTwoNumbers;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\RearrangeStringToTwoNumbers\RearrangeStringToTwoNumbers;
9+
10+
/**
11+
* Tests for the "Rearrange string to two numbers" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\RearrangeStringToTwoNumbers\RearrangeStringToTwoNumbers
14+
* @group rearrangeStringToTwoNumbers
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new RearrangeStringToTwoNumbers();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Two digits".
26+
*
27+
* @group rearrangeStringToTwoNumbers_twoDigits
28+
*/
29+
public function testCanExecuteTwoDigits(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - two digits.txt',
33+
"2 7" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Too many digits".
39+
*
40+
* @group rearrangeStringToTwoNumbers_tooManyDigits
41+
*/
42+
public function testCanExecuteTooManyDigits(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - too many digits.txt',
46+
"-1 -1" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Maximum B".
52+
*
53+
* @group rearrangeStringToTwoNumbers_maximumB
54+
*/
55+
public function testCanExecuteMaximumB(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - maximum B.txt',
59+
"400005555567778999 1000000000000000000" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Too many 0's".
65+
*
66+
* @group rearrangeStringToTwoNumbers_tooMany0s
67+
*/
68+
public function testCanExecuteTooMany0s(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - too many 0s.txt',
72+
"-1 -1" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Maximum B with 0".
78+
*
79+
* @group rearrangeStringToTwoNumbers_maximumBWith0
80+
*/
81+
public function testCanExecuteMaximumBWith0(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - maximum B with 0.txt',
85+
"0 1000000000000000000" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Small A maximum B".
91+
*
92+
* @group rearrangeStringToTwoNumbers_smallAMaximumB
93+
*/
94+
public function testCanExecuteSmallAMaximumB(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - small A maximum B.txt',
98+
"4 1000000000000000000" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Small A big B".
104+
*
105+
* @group rearrangeStringToTwoNumbers_smallABigB
106+
*/
107+
public function testCanExecuteSmallABigB(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - small A big B.txt',
111+
"20 200223334577788999" . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Too many 0's".
117+
*
118+
* @group rearrangeStringToTwoNumbers_tooMany0s2
119+
*/
120+
public function testCanExecuteTooMany0s2(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - too many 0s - 2.txt',
124+
"-1 -1" . PHP_EOL
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "Too few digits".
130+
*
131+
* @group rearrangeStringToTwoNumbers_tooFewDigits
132+
*/
133+
public function testCanExecuteTooFewDigits(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - too few digits.txt',
137+
"-1 -1" . PHP_EOL
138+
);
139+
}
140+
141+
/**
142+
* Test that the code can be executed for "Too many digits".
143+
*
144+
* @group rearrangeStringToTwoNumbers_tooManyDigits2
145+
*/
146+
public function testCanExecuteTooManyDigits2(): void
147+
{
148+
$this->expectExecuteOutputAnswer(
149+
__DIR__ . '/input/10 - too many digits.txt',
150+
"-1 -1" . PHP_EOL
151+
);
152+
}
153+
154+
/**
155+
* Test that the code can be executed for "Zero".
156+
*
157+
* @group rearrangeStringToTwoNumbers_zero
158+
*/
159+
public function testCanExecuteZero(): void
160+
{
161+
$this->expectExecuteOutputAnswer(
162+
__DIR__ . '/input/11 - zero.txt',
163+
"0 400004566667788899" . PHP_EOL
164+
);
165+
}
166+
167+
/**
168+
* Test that the code can be executed for "Maximum".
169+
*
170+
* @group rearrangeStringToTwoNumbers_maximum
171+
*/
172+
public function testCanExecuteMaximum(): void
173+
{
174+
$this->expectExecuteOutputAnswer(
175+
__DIR__ . '/input/12 - maximum.txt',
176+
"1000000000000000000 1000000000000000000" . PHP_EOL
177+
);
178+
}
179+
180+
/**
181+
* Test that the code can be executed for "Big with 0's".
182+
*
183+
* @group rearrangeStringToTwoNumbers_bigWith0s
184+
*/
185+
public function testCanExecuteBigWith0s(): void
186+
{
187+
$this->expectExecuteOutputAnswer(
188+
__DIR__ . '/input/13 - big with 0s.txt',
189+
"200000222233333345 566777777888999999" . PHP_EOL
190+
);
191+
}
192+
193+
/**
194+
* Test that the code can be executed for "Big".
195+
*
196+
* @group rearrangeStringToTwoNumbers_big
197+
*/
198+
public function testCanExecuteBig(): void
199+
{
200+
$this->expectExecuteOutputAnswer(
201+
__DIR__ . '/input/14 - big.txt',
202+
"111112222333355566 777778888889999999" . PHP_EOL
203+
);
204+
}
205+
206+
/**
207+
* Test that the code can be executed for "Internal zeros".
208+
*
209+
* @group rearrangeStringToTwoNumbers_internalZeros
210+
*/
211+
public function testCanExecuteInternalZeros(): void
212+
{
213+
$this->expectExecuteOutputAnswer(
214+
__DIR__ . '/input/15 - internal zeros.txt',
215+
"100022233334444 45555555666668899" . PHP_EOL
216+
);
217+
}
218+
219+
/**
220+
* Test that the code can be executed for "Small A big B".
221+
*
222+
* @group rearrangeStringToTwoNumbers_smallABigB
223+
*/
224+
public function testCanExecuteInternalSmallABigB(): void
225+
{
226+
$this->expectExecuteOutputAnswer(
227+
__DIR__ . '/input/16 - small A big B.txt',
228+
"5 555566666667778899" . PHP_EOL
229+
);
230+
}
231+
232+
/**
233+
* Test that the code can be executed for "Small A big B".
234+
*
235+
* @group rearrangeStringToTwoNumbers_smallABigB2
236+
*/
237+
public function testCanExecuteInternalSmallABigB2(): void
238+
{
239+
$this->expectExecuteOutputAnswer(
240+
__DIR__ . '/input/17 - small A big B - 2.txt',
241+
"4 44455566667788" . PHP_EOL
242+
);
243+
}
244+
245+
/**
246+
* Test that the code can be executed for "Two digits".
247+
*
248+
* @group rearrangeStringToTwoNumbers_twoDigits
249+
*/
250+
public function testCanExecuteInternaltwoDigits(): void
251+
{
252+
$this->expectExecuteOutputAnswer(
253+
__DIR__ . '/input/18 - two digits.txt',
254+
"9 9" . PHP_EOL
255+
);
256+
}
257+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
72
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8784688955737839773875997657797875797
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0800795705000904561000705000000905000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0000000000100000000000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10000000000000000000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
00000004000000000001
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
79380248390522737902

0 commit comments

Comments
 (0)