Add in-progress of day 6

This commit is contained in:
Tristan 2023-12-08 09:33:55 +01:00
parent 1369b76f42
commit da9286a477
Signed by: trizz
SSH Key Fingerprint: SHA256:Xsd2dTN+ZC3OZWfvuKIDMQ/1lWicuINSEPgRQw/CJT8
3 changed files with 59 additions and 0 deletions

57
data/Y23/day6/Day6.php Normal file
View File

@ -0,0 +1,57 @@
<?php
namespace trizz\AdventOfCode\Y23;
final class Day6 extends \trizz\AdventOfCode\Solution
{
public static null|int|string $part1ExampleResult = null;
public static null|int|string $part1Result = null;
public static null|int|string $part2ExampleResult = null;
public static null|int|string $part2Result = null;
/*
0 0
1 6
2 10
3 12
4 12
5 10
6 6
7 0
*/
#[\Override]
public function part1(array $data): int
{
$time = array_filter(explode(' ', $data[0]));
$distance = array_filter(explode(' ', $data[1]));
unset($time[0], $distance[0]);
$time = array_map('intval', array_values($time));
$distance = array_map('intval', array_values($distance));
$maxDistance = [];
foreach ($time as $key => $value) {
for ($i = 0; $i < $value; ++$i) {
// dump($time[$key]);
$maxDistance[$key][] = 7 + ($time[$key] - $i);
}
// dd($maxDistance);
}
// dd($maxDistance);
return -1;
}
#[\Override]
public function part2(array $data): int
{
return -1;
}
}

0
data/Y23/day6/data.txt Normal file
View File

View File

@ -0,0 +1,2 @@
Time: 7 15 30
Distance: 9 40 200