commit 51aaf9af97cde55cd10817bd60b78e361638e3db Author: Clement Desmidt Date: Thu Dec 1 09:06:21 2022 +0100 :tada: Initialise le repo comme tous les ans diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f81980 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +input.txt +/.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..6cf7123 --- /dev/null +++ b/README.md @@ -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 🔲🔲 | diff --git a/add.sh b/add.sh new file mode 100755 index 0000000..89c9837 --- /dev/null +++ b/add.sh @@ -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 \ No newline at end of file diff --git a/day_1/part_1.php b/day_1/part_1.php new file mode 100644 index 0000000..e179dcf --- /dev/null +++ b/day_1/part_1.php @@ -0,0 +1,8 @@ + array_sum(explode("\n", $elf)), + explode("\n\n", file_get_contents('./input.txt')) + ) +); diff --git a/day_1/part_2.php b/day_1/part_2.php new file mode 100644 index 0000000..657852b --- /dev/null +++ b/day_1/part_2.php @@ -0,0 +1,11 @@ + array_sum(explode("\n", $elf)), + explode("\n\n", file_get_contents('./input.txt')) +); + +rsort($calories); + +echo array_sum(array_slice($calories, 0, 3)); +