Skip to content

Commit 2b9e673

Browse files
committed
Adding tests for "Maximum sub-sequence".
1 parent 7ddcccd commit 2b9e673

File tree

8 files changed

+113
-0
lines changed

8 files changed

+113
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Tests for "Find the missing plus signs in addition".
3131
- Tests for "Magic stones".
3232
- Tests for "Game of life".
33+
- Tests for "Maximum sub-sequence".
3334

3435
## [3.13.0] - 2022-09-30
3536
### Added
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\MaximumSubSequence;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Maximum sub-sequence" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/maximum-sub-sequence
12+
*/
13+
class MaximumSubSequence implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $N);
18+
$inputs = explode(" ", fgets($stdin));
19+
for ($i = 0; $i < $N; $i++)
20+
{
21+
$l = intval($inputs[$i]);
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("1 2 3 4 5\n");
27+
}
28+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\MaximumSubSequence;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\MaximumSubSequence\MaximumSubSequence;
9+
10+
/**
11+
* Tests for the "Maximum sub-sequence" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\MaximumSubSequence\MaximumSubSequence
14+
* @group maximumSubSequence
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new MaximumSubSequence();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Simple".
26+
*
27+
* @group maximumSubSequence_simple
28+
*/
29+
public function testCanExecuteSimple(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - simple.txt',
33+
"0 1 2" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Bigger Ik".
39+
*
40+
* @group maximumSubSequence_biggerIk
41+
*/
42+
public function testCanExecuteBiggerIk(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - bigger Ik.txt',
46+
"999 1000 1001 1002 1003 1004 1005" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Two choices".
52+
*
53+
* @group maximumSubSequence_twoChoices
54+
*/
55+
public function testCanExecuteTwoChoices(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - two choices.txt',
59+
"0 1 2" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Even bigger Ik".
65+
*
66+
* @group maximumSubSequence_evenBiggerIk
67+
*/
68+
public function testCanExecuteEvenBiggerIk(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - even bigger Ik.txt',
72+
file_get_contents(__DIR__ . '/output/04 - even bigger Ik.txt')
73+
);
74+
}
75+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5
2+
0 -1 1 2 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
19
2+
8 12 999 1000 0 1001 1 2 49 9 8 3 1002 4 -456 5 1003 1004 1005
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
6
2+
1 0 2 1 3 2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1178
2+
2970942 -1242452 -3159308 -275040 9441832 412154 4835060 -7436208 -7795294 -9726488 -9370994 -7304850 -9182944 -165674 5059462 666744 850942 -3953012 -8355380 -377896 541988 3100492 -4851740 -8183406 -3260644 854110 1545144 2624696 -9455346 8017690 -9268344 4904152 7668874 -5320788 -2421278 -5031484 2738770 -210528 4967128 -6012912 -9145394 3118552 8765216 9061362 8543574 8517134 -569790 -3832662 -7164718 -7015256 9818550 6289302 6016620 1664364 -1532202 4904153 -4084248 3376670 6792612 141434 7994464 -9805538 4994638 -4396090 5615884 -2722510 -4497348 360910 -1917182 -6328972 -6472730 7550118 -419286 -5511200 -4034742 -9817542 7978198 -5199236 2347682 5036180 -8938900 -4668528 966380 -2307542 -2036194 3212258 303812 -4909766 -962278 4204354 -7785484 5160994 1290260 -7745680 -3168610 -3443406 -5802160 9186674 -9564900 -1912830 -6043184 2156614 993954 9642856 4847920 -9498812 5844100 -3121982 8905458 -9880686 -7378674 7863986 3647488 9516688 -3491238 6683178 -2928022 2867404 1598498 -8217932 3937094 -8058330 2975920 -7064428 -3204348 2746528 -4607702 -5950982 -8378496 1603636 -7133796 4896524 780994 -1127574 5425476 -2282638 -6228732 4904154 9361552 -4419730 -5001016 -698760 7289826 -8860660 7506058 -4311604 3493346 6317792 -2973298 -5253324 -3993628 6766316 2312120 4223666 4096420 -5875340 1339454 8421068 8231392 535692 3113226 -6511942 5252168 -6173464 2196174 -7808328 3918012 4904155 -658332 2932128 -330912 -8654904 -1170064 -1621298 -6011474 -2612374 -2359692 -9510092 3860980 -3307262 -9440 4331992 -5241990 -9815736 4238032 -8048460 -4836780 -9653970 -9768226 -209272 3391740 -4717272 -4050282 -917638 -3780940 9900476 7841614 8717618 -1180028 -8835784 1110802 6332878 -1219720 -8803396 -9627666 7152752 2153094 9425464 -3521024 -3802894 -9190824 7874844 -3012958 -8121254 3281870 4904156 9301302 1833890 2555394 9366066 -8962484 2850644 5593356 1284468 -9889270 3982526 -2957922 -4180894 7021618 -9291716 5125098 -8383554 113686 3741930 -6671398 -1696614 -6475446 9896922 -8458980 7011314 -7949610 2671346 3866984 -5025336 -5679246 -4807236 -6304660 -6924446 -1659500 7167834 -8418750 9994422 5823230 -4508012 3541680 58938 -6140914 -1160756 -4504884 583016 7437044 349806 6679496 3790926 -7589970 5913252 9317364 -2540864 4904157 3967610 1468630 -6410428 5995202 5781548 9241670 2647808 5576094 -7337664 -1826144 -3659100 -3594110 -3261286 -9844450 -5851844 2301512 9875498 1333112 -8469486 -1689006 6706338 8276368 8368770 4111876 -1668188 -8258634 -7747180 6657212 6430268 1544668 -1576474 -2459812 -9828404 3387168 2650830 1611688 -3571094 20730 503622 7883470 -4712208 -2568720 -6600736 4904158 1117842 -1225480 -4999806 -2610920 1062294 7213232 3412978 -7578580 -4544402 3468120 -5955456 -1862532 -5457850 5243908 -2732994 9041110 -2929846 -9155210 -9784978 7363044 -4025164 -9337120 3114160 -5739236 9992386 -990122 -4029840 -3658814 -3784458 1600074 -419856 7361008 1882932 4904159 -2841082 -6454344 -1779478 -7600740 -2522384 9256684 -5677000 -5873858 -3388868 -1925282 4097880 469548 -4135570 8731336 2086234 8139088 5133726 363862 6410904 -1961464 -5034128 8535302 423580 -8238224 -3379080 7967304 -5170072 -6786890 4946568 -7951962 -4814702 7933264 4287310 9565514 4904160 8259066 -9350274 1679254 -6458260 -5686394 480780 -8200182 5573066 7268440 6825724 9690652 -9165868 -5746312 -6241858 -2363592 -9468428 1229760 7695684 8097284 9002934 7191816 7028746 -8231304 -1950890 1644372 7099588 -8171854 2344664 9954224 -1252020 4429498 -2964370 4240210 7695528 -8625122 -5250840 1315018 -457742 6425154 7999320 1000178 725830 9978288 8925284 2582202 -6475066 3710740 -8732492 4995410 9082184 9514002 -7800594 8341134 -8050128 8957280 -3573980 4631524 -8021314 9452652 -9856504 -9351910 -1452816 -9981636 -4878416 1020564 1451258 7812260 -6428824 -2176564 -488162 -1980634 4904161 8592538 -4751830 -704704 8072178 3389352 -8366472 -8984380 -8588086 -9786226 -7864824 -5439966 -1047874 5415442 9683224 -3846 -9587464 -703118 5520688 6914260 5275896 -8385698 8603992 8147432 8583792 -8162648 3411414 8192250 -4572822 4904162 5052274 -2139054 9669048 6935560 -2288928 9331374 -6825824 6075948 -441730 -2682218 4443934 3503426 -21992 8562050 -6654496 -7976972 -3323208 -5754894 8999870 -1692200 -6829614 -335912 6885838 -6561330 182678 6545130 -8297628 -8614600 1201420 859626 -1146056 -5225274 -3717962 -7304368 9379822 -6994236 4856372 -9792508 5637162 -7584420 2809758 4904163 -5250764 1745470 -4006220 -2213380 -6634666 -1731390 -419470 7959906 -7730198 -6947222 1989856 -6469834 4677776 6975862 2510674 -8960160 4190718 -4966156 -7005276 -7852302 -2532762 706706 8751300 6304450 2085366 -5069742 4894302 3219188 -983714 4646170 5179442 6759538 6567156 -1274588 -352764 -3180492 -1905608 4554060 -9190994 -8838700 -9816242 2984698 2276066 4646866 -3184664 7541168 4904164 308268 -6070294 -6780312 9319574 60664 -2388538 -1845202 -2451400 -8855046 6624056 567454 7550204 -4900434 6528904 9282546 9603240 8514978 7563732 -680424 -3197788 -4065868 -8877536 6865340 -6979490 3851746 8710882 -4977084 1023502 1599114 4247816 8556806 -6503106 -2095780 4943464 -1552104 -9696704 -5852774 3744446 1169090 -8501750 7490156 9756810 -6793774 5073600 8731886 -8704714 -9585770 -1957874 -9611952 -7173062 -7767702 5653944 -1045568 195350 2584136 -2467732 34002 9780290 -6011060 -2323958 2286912 -5250364 8856216 -8698006 -1588286 9176678 -4969322 8688170 -8248292 -2954278 3700970 8202960 -8374988 2330072 4729936 4904165 3842524 8265160 -940038 -9029872 -4066162 -9017632 -3451370 -1087118 -756234 7797298 -5692990 -9995962 9770624 -4956228 -3378574 -5565942 -902182 -6941464 9175030 1549230 2161092 4634430 -4841790 5380532 8489908 -6245966 -6744606 -2820490 8266154 6224054 6912114 5338414 5196514 -8507702 5829930 -6990736 4904166 -6051574 -3747426 6239292 3418102 7469790 7135666 3783082 5224896 -25534 -3513572 8236340 -2970270 6278552 -8195220 -2752262 -232262 80342 8278832 -6411172 6877746 -8934412 -8459640 -3963256 9113208 2812318 7086022 -5326954 -5663114 5316590 -8588906 5433790 -7927410 743830 -667348 -1760010 -1809520 1796736 1500908 -208580 -7905866 5333036 8197390 1907446 -5944584 9691400 5830974 8488952 -5205968 3277736 9865516 -5850214 4183768 -2012426 -8218482 244314 -8778828 -7775994 217686 1522452 7023882 4904167 -2590832 -9160758 9294822 7672550 -1675732 7347708 -4754382 8938428 3750030 -8981202 -7904468 9718590 9049586 9448532 6806918 -7598534 7214074 9683458 3332770 1972914 6662078 -8891500 6187880 3860548 -7934286 1671330 3865548 -4795020 1712788 4751336 7793434 -5562640 7597354 -8026566 -914530 -8253264 -7845656 6782750 -7594414 -5563706 4904168 -5791746 -6537626 -3214846 398174 -1738554 7572382 5213836 4443570 4667710 -376154 -8239482 203922 -8932614 8960358 5164200 2903962 8167674 4997164 3082118 -1877224 -5966280 180236 -8676294 -9980746 -7414910 4715116 2233556 -7224896 -1110444 4904169 -5581144 -249060 4410116 -8867116 4275116 9682996 -7852328 1043448 8391846 -7268022 -1875310 -2266334 -7672626 6068442 1733190 6880214 522234 3111890 -6275600 -3439840 2569792 -8214716 4503012 -3263298 -6128702 -4579814 1114304 2923536 -3591748 -902334 -6103040 8552386 -5229478 3827310 -9048716 6993078 -6691502 -6394418 -2899394 -8615002 4519180 3713920 2438440 -1099398 -5514522 -7692864 -2265916 9836832 -5220110 7995940 8211874 6352020 -1023986 6063106 -6955064 -7109602 4904170 978856 -6882210 -4129986 8087948 -8661198 -9330210 5311908 -7029964 2662596 2130388 2949792 5858080 -1996950 1932660 -1676116 -5168852 5726006 6273706 -1746612 -8025190 1001638 4139462 -5272626 -3129100 -9087142 8992924 4904171 3422824 1630672 5374378 1659776 -4736752 -8837948 -7582634 -4295858 9055350 9307814 4398478 9366824 -6596402 7072066 4341048 434348 -3571432 3557464 -3159588 9778978 -584202 2441830 -7814742 -4400400 -4075682 -5841370 -511316 -1619074 -7322058 6626144 1513856 -9654820 -8250488 5696190 -7896784 7191032 -7408000 -2807336 1150680 -651790 8148140 -9543100 9034276 2790670 3437034 3162086 -6543300 -4790562 -4032014 -885804 -1073696 -1202344 6811754 2180940 -2948024 9700196 5244506 -3161326 4924756 4385590 -7812290 -5146666 -6893200 2410070 -7642922 2131624 4129038 -4734320 2640250 8620994 2657254 1492138 4219172 9052426 3151214 687876 4591512 2298146 3827432 -7604874 -6657930 -2480674 -9593808 -9726828 -3644840 1051424 6289880 -111102 6204490 2800918 -4263612 -4486966 -6388330 -8757676 8504346 2880882 -3731004 6982842 1356176 3135694 -957030 3281668 -9611936 3913696 7832314 6240170 -2235890 5948830 -7112756 -41462 3498772 1442976 9029998 1462710 6307168 -1222370 2274090 -7827848 -5125522 -128112 -3776580 -1525864 6013400 4585398 7585368 -8784532 6121782 -6260294 3835094 2308686 3393260 -8282986 252916 -4007692 2690520 -4758244 8884380 4335468 -4675482 3092758 2795746 -9017650 -7978364 -9093180 8182794 7222510 -4234522 -9534854 -1257950 -8390366 -6264316 -5099292 1583544 4435428 5937036 4902084 -4131342 -9864830 6549162 7933306 -1647260 8503162 9411760 3007594 -9931606 1576102 -3275986 -3381772 8031718 7065848 -1384082 2805882 -1582526 1301746 2980260 4298868 6339628 -863208 4371750 7348550 2033144 -9258024 2093718 764712 -3454804 8292232 -353828 8905292 632040 -3528196 -3517946 8298510 3810122 322614 3762084 -2916240 5033262 9390326 4263108 -9625028 825510 -7311126 -9085090 -9238416 3573652 7232032 -9374306 5337548 -6336528 -5060476 4224726 2225878 2543590 2596524 -5860458 3475914 -7201494 -5486082 9723544 -221220 -9772498 4697676 5210356 1104810 2027520 7225466 242992 3088688 7824980 2255496 -5781236 -5666472 -3875054 -313074 5194280 -7964398 -9048632 -1938734 -8145742 5661098 -9584086 -8797456 -7928164 6216468 -7532954 1238078 -4995306 1592404 -2719098 -1310122 -9871912 -5932722 4522322 -8894348 -9865682 -7946352 -6631180 -7450336 8834822 5025108 3441138 -6432556 -1381226 -9496840 -4744290 7685274 8122256 -5097060 4353030 9509258 5514986 6890734 5992928 9030672 -2291378 6118102 3675648
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4904152 4904153 4904154 4904155 4904156 4904157 4904158 4904159 4904160 4904161 4904162 4904163 4904164 4904165 4904166 4904167 4904168 4904169 4904170 4904171

0 commit comments

Comments
 (0)