18 lines
399 B
PHP
18 lines
399 B
PHP
<?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); |