Finit le jour 2 et commence le 1 et le 3

This commit is contained in:
Clement Desmidt
2025-12-10 15:01:52 +01:00
commit 8b73ada230
6 changed files with 139 additions and 0 deletions

18
day_3/part_1.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
$banks = explode("\n", file_get_contents('./input.txt'));
$output_joltage = [];
foreach ($banks as $bank) {
$a_bank = str_split($bank);
$max = max(array_slice($a_bank,0,count($a_bank)-1));
$i = array_search($max, $a_bank);
$right_part = array_slice($a_bank, $i+1);
$max2 = max($right_part);
$output_joltage[] = (int) $max.$max2;
}
echo array_sum($output_joltage);