advent_of_code_2022/day_6/part_1.php

10 lines
259 B
PHP
Raw Normal View History

2022-12-06 11:15:10 +01:00
<?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;
}
}