π Initialise le repo comme tous les ans
This commit is contained in:
commit
51aaf9af97
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
input.txt
|
||||||
|
/.idea
|
10
README.md
Normal file
10
README.md
Normal 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
19
add.sh
Executable 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
8
day_1/part_1.php
Normal 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
11
day_1/part_2.php
Normal 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));
|
||||||
|
|
Loadingβ¦
Reference in New Issue
Block a user