26 lines
532 B
PHP
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; |