Finit le jour 6

This commit is contained in:
Clement Desmidt 2022-12-06 11:15:10 +01:00
parent ff57718fa1
commit c563849e0c
3 changed files with 21 additions and 1 deletions

View File

@ -5,6 +5,6 @@
| Lundi | Mardi | Mercredi | Jeudi | Vendredi | Samedi | Dimanche |
|---------|---------|----------|---------|----------|---------|----------|
| | | | 1 ✅✅ | 2 ✅✅ | 3 ✅✅ | 4 ✅✅ |
| 5 ✅✅ | 6 🔲🔲 | 7 🔲🔲 | 8 🔲🔲 | 9 🔲🔲 | 10 🔲🔲 | 11 🔲🔲 |
| 5 ✅✅ | 6 ✅✅ | 7 🔲🔲 | 8 🔲🔲 | 9 🔲🔲 | 10 🔲🔲 | 11 🔲🔲 |
| 12 🔲🔲 | 13 🔲🔲 | 14 🔲🔲 | 15 🔲🔲 | 16 🔲🔲 | 17 🔲🔲 | 18 🔲🔲 |
| 19 🔲🔲 | 20 🔲🔲 | 21 🔲🔲 | 22 🔲🔲 | 23 🔲🔲 | 24 🔲🔲 | 25 🔲🔲 |

10
day_6/part_1.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$buffer = str_split(file_get_contents('./input.txt'));
for ($start = 0, $max = count($buffer); $start < $max; $start++) {
$slice = array_slice($buffer, $start, 4);
if (count(array_unique($slice)) === 4) {
echo $start + 4; exit;
}
}

10
day_6/part_2.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$buffer = str_split(file_get_contents('./input.txt'));
for ($start = 0, $max = count($buffer); $start < $max; $start++) {
$slice = array_slice($buffer, $start, 14);
if (count(array_unique($slice)) === 14) {
echo $start + 14; exit;
}
}