πŸŽ‰ Initialise le repo comme tous les ans

This commit is contained in:
Clement Desmidt 2022-12-01 09:06:21 +01:00
commit 51aaf9af97
5 changed files with 50 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
input.txt
/.idea

10
README.md Normal file
View File

@ -0,0 +1,10 @@
# Advent Of Code 2022
---
| Lundi | Mardi | Mercredi | Jeudi | Vendredi | Samedi | Dimanche |
|---------|---------|----------|---------|----------|---------|----------|
| | | | 1 βœ…βœ… | 2 πŸ”²πŸ”² | 3 πŸ”²πŸ”² | 4 πŸ”²πŸ”² |
| 5 πŸ”²πŸ”² | 6 πŸ”²πŸ”² | 7 πŸ”²πŸ”² | 8 πŸ”²πŸ”² | 9 πŸ”²πŸ”² | 10 πŸ”²πŸ”² | 11 πŸ”²πŸ”² |
| 12 πŸ”²πŸ”² | 13 πŸ”²πŸ”² | 14 πŸ”²πŸ”² | 15 πŸ”²πŸ”² | 16 πŸ”²πŸ”² | 17 πŸ”²πŸ”² | 18 πŸ”²πŸ”² |
| 19 πŸ”²πŸ”² | 20 πŸ”²πŸ”² | 21 πŸ”²πŸ”² | 22 πŸ”²πŸ”² | 23 πŸ”²πŸ”² | 24 πŸ”²πŸ”² | 25 πŸ”²πŸ”² |

19
add.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/zsh
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
NUMBER=$1
if [ ! -d "${SCRIPT_PATH}/day_${NUMBER}" ]; then
mkdir "${SCRIPT_PATH}/day_${NUMBER}"
else
echo "folder ${SCRIPT_PATH}/day_${NUMBER} already exists"
exit
fi
cd "${SCRIPT_PATH}/day_${NUMBER}" || exit
touch input.txt part_1.php part_2.php
echo "DONE"
exit

8
day_1/part_1.php Normal file
View File

@ -0,0 +1,8 @@
<?php
echo max(
array_map(
static fn($elf) => array_sum(explode("\n", $elf)),
explode("\n\n", file_get_contents('./input.txt'))
)
);

11
day_1/part_2.php Normal file
View File

@ -0,0 +1,11 @@
<?php
$calories = array_map(
static fn($elf) => array_sum(explode("\n", $elf)),
explode("\n\n", file_get_contents('./input.txt'))
);
rsort($calories);
echo array_sum(array_slice($calories, 0, 3));