|
| 1 | +# Codingame |
| 2 | + |
| 3 | +A project to test your [Codingame](https://www.codingame.com/) PHP code. It is not intended to have solutions. |
| 4 | +It only contains PHPUnit tests to let you code in your favorite IDE, outside of the Codingame web site. |
| 5 | + |
| 6 | +[](https://github.com/cyrilverloop/codingame/blob/trunk/LICENSE) |
| 7 | +[](https://www.php.net/) |
| 8 | + |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +Downloading the project : |
| 13 | +```shellsession |
| 14 | +user@host ~$ cd [PATH_WHERE_TO_PUT_THE_PROJECT] # E.g. ~/projects/ |
| 15 | +user@host projects$ git clone https://github.com/cyrilverloop/codingame.git |
| 16 | +user@host projects$ cd codingame |
| 17 | +``` |
| 18 | + |
| 19 | +Installing the dependencies : |
| 20 | +```shellsession |
| 21 | +user@host codingame$ docker compose run --rm app composer install -o |
| 22 | +user@host codingame$ docker compose run --rm app phive install --trust-gpg-keys 4AA394086372C20A,12CE0F1D262429A5,31C7E470E2138192 |
| 23 | +``` |
| 24 | + |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +Every classes in `./src/` contains an `execute()` method with the default Codingame code. |
| 29 | +You can add every PHP code you want in this directory to solve the puzzles. |
| 30 | + |
| 31 | +Executing all the tests : |
| 32 | +```shellsession |
| 33 | +user@host codingame$ docker compose run --rm app ./tools/phpunit -c ./ci/phpunit.xml |
| 34 | +``` |
| 35 | + |
| 36 | +Executing tests for a particular puzzle : |
| 37 | +```shellsession |
| 38 | +user@host codingame$ docker compose run --rm app ./tools/phpunit -c ./ci/phpunit.xml --group [GROUP_NAME] |
| 39 | +``` |
| 40 | + |
| 41 | +To view the list of test groups : |
| 42 | +```shellsession |
| 43 | +user@host codingame$ docker compose run --rm app ./tools/phpunit -c ./ci/phpunit.xml --list-groups |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +## Back to Codingame |
| 48 | + |
| 49 | +When you copy your code back to Codingame, you must change every `$stdin` in `fscanf()`, `stream_get_line()`, ... |
| 50 | +by `STDIN` : |
| 51 | +```php |
| 52 | +// In this project : |
| 53 | +fscanf($stdin, "%d", $N); |
| 54 | +``` |
| 55 | + |
| 56 | +```php |
| 57 | +// On Codingame : |
| 58 | +fscanf(STDIN, "%d", $N); |
| 59 | +``` |
| 60 | + |
| 61 | + |
| 62 | +## Timed out |
| 63 | + |
| 64 | +Your code can work through this project and timed out on Codingame. |
| 65 | +It means your solution is not optimum and you should find another algorithm. |
0 commit comments