Update stuff

This commit is contained in:
2024-12-01 11:30:31 +01:00
parent d3f2406b23
commit 6915c35fed
13 changed files with 784 additions and 805 deletions

View File

@ -7,10 +7,14 @@ use trizz\AdventOfCode\Solution;
final class Day1 extends Solution
{
public static null|int|string $part1ExampleResult = 11;
public static null|int|string $part1Result = 1882714;
public static null|int|string $part2ExampleResult = 31;
public static null|int|string $part2Result = null;
public static null|int|string $part1Result = 1882714;
public static null|int|string $part2ExampleResult = 31;
public static null|int|string $part2Result = 19437052;
#[\Override]
public function part1(array $data): int
{
[$listLeft, $listRight] = $this->getList($data);
@ -23,13 +27,14 @@ final class Day1 extends Solution
return $score;
}
#[\Override]
public function part2(array $data): int
{
$score = 0;
[$listLeft, $listRight] = $this->getList($data);
foreach ($listLeft as $index => $left) {
$right = count(array_filter($listRight, fn ($x) => $x === $left));
$right = count(array_filter($listRight, fn ($x): bool => $x === $left));
if ($right > 0) {
$score += $left * $right;
}