Files
advent_of_code_2025/day_7/part_1.php
2026-01-12 15:34:23 +01:00

26 lines
532 B
PHP

<?php
include '../functions.php';
$rows = explode("\n", file_get_contents("input.txt"));
$count_split = 0;
$indexes = [];
$indexes[] = array_search('S', str_split(array_shift($rows)));
foreach ($rows as $row) {
foreach ($indexes as $index) {
if ($row[$index] === '^') {
$indexes[] = $index-1;
$indexes[] = $index+1;
unset($indexes[array_search($index, $indexes)]);
$indexes = array_unique($indexes);
$count_split++;
}
}
}
echo $count_split;