Compare commits
2 Commits
7a594d4c2e
...
a9ee290924
Author | SHA1 | Date | |
---|---|---|---|
a9ee290924 | |||
d3f2406b23 |
62
composer.lock
generated
62
composer.lock
generated
@ -628,16 +628,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v7.1.8",
|
||||
"version": "v7.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5"
|
||||
"reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/ff04e5b5ba043d2badfb308197b9e6b42883fcd5",
|
||||
"reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/23c8aae6d764e2bae02d2a99f7532a7f6ed619cf",
|
||||
"reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -701,7 +701,7 @@
|
||||
"terminal"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/console/tree/v7.1.8"
|
||||
"source": "https://github.com/symfony/console/tree/v7.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -717,20 +717,20 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-06T14:23:19+00:00"
|
||||
"time": "2024-11-06T14:24:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
"version": "v3.5.0",
|
||||
"version": "v3.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/deprecation-contracts.git",
|
||||
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1"
|
||||
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
|
||||
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
|
||||
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
|
||||
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -768,7 +768,7 @@
|
||||
"description": "A generic function and convention to trigger deprecation notices",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0"
|
||||
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -784,7 +784,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-18T09:32:20+00:00"
|
||||
"time": "2024-09-25T14:20:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
@ -1106,16 +1106,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
"version": "v3.5.0",
|
||||
"version": "v3.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/service-contracts.git",
|
||||
"reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f"
|
||||
"reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f",
|
||||
"reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f",
|
||||
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0",
|
||||
"reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1169,7 +1169,7 @@
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/service-contracts/tree/v3.5.0"
|
||||
"source": "https://github.com/symfony/service-contracts/tree/v3.5.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1185,20 +1185,20 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-18T09:32:20+00:00"
|
||||
"time": "2024-09-25T14:20:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/string",
|
||||
"version": "v7.1.8",
|
||||
"version": "v7.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/string.git",
|
||||
"reference": "591ebd41565f356fcd8b090fe64dbb5878f50281"
|
||||
"reference": "446e0d146f991dde3e73f45f2c97a9faad773c82"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/string/zipball/591ebd41565f356fcd8b090fe64dbb5878f50281",
|
||||
"reference": "591ebd41565f356fcd8b090fe64dbb5878f50281",
|
||||
"url": "https://api.github.com/repos/symfony/string/zipball/446e0d146f991dde3e73f45f2c97a9faad773c82",
|
||||
"reference": "446e0d146f991dde3e73f45f2c97a9faad773c82",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1256,7 +1256,7 @@
|
||||
"utf8"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/string/tree/v7.1.8"
|
||||
"source": "https://github.com/symfony/string/tree/v7.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1272,7 +1272,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-13T13:31:21+00:00"
|
||||
"time": "2024-11-13T13:31:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "toolkit/cli-utils",
|
||||
@ -5820,16 +5820,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v7.1.8",
|
||||
"version": "v7.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-dumper.git",
|
||||
"reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8"
|
||||
"reference": "c6a22929407dec8765d6e2b6ff85b800b245879c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
|
||||
"reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/c6a22929407dec8765d6e2b6ff85b800b245879c",
|
||||
"reference": "c6a22929407dec8765d6e2b6ff85b800b245879c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -5845,7 +5845,7 @@
|
||||
"symfony/http-kernel": "^6.4|^7.0",
|
||||
"symfony/process": "^6.4|^7.0",
|
||||
"symfony/uid": "^6.4|^7.0",
|
||||
"twig/twig": "^3.0.4"
|
||||
"twig/twig": "^3.12"
|
||||
},
|
||||
"bin": [
|
||||
"Resources/bin/var-dump-server"
|
||||
@ -5883,7 +5883,7 @@
|
||||
"dump"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/var-dumper/tree/v7.1.8"
|
||||
"source": "https://github.com/symfony/var-dumper/tree/v7.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -5899,7 +5899,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-08T15:46:42+00:00"
|
||||
"time": "2024-11-08T15:48:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ta-tikoma/phpunit-architecture-test",
|
||||
|
61
data/Y24/day1/Day1.php
Normal file
61
data/Y24/day1/Day1.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace trizz\AdventOfCode\Y24;
|
||||
|
||||
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 function part1(array $data): int
|
||||
{
|
||||
[$listLeft, $listRight] = $this->getList($data);
|
||||
$score = 0;
|
||||
foreach ($listLeft as $index => $left) {
|
||||
$right = $listRight[$index];
|
||||
$score += abs($left - $right);
|
||||
}
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
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));
|
||||
if ($right > 0) {
|
||||
$score += $left * $right;
|
||||
}
|
||||
}
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int,string> $data
|
||||
*
|
||||
* @return array<int,int[]>
|
||||
*/
|
||||
private function getList(array $data): array
|
||||
{
|
||||
$listLeft = [];
|
||||
$listRight = [];
|
||||
foreach ($data as $x) {
|
||||
[$a1, $_, $_, $b1] = explode(' ', $x);
|
||||
$listLeft[] = (int) $a1;
|
||||
$listRight[] = (int) $b1;
|
||||
}
|
||||
|
||||
sort($listLeft);
|
||||
sort($listRight);
|
||||
|
||||
return [$listLeft, $listRight];
|
||||
}
|
||||
}
|
1001
data/Y24/day1/data.txt
Normal file
1001
data/Y24/day1/data.txt
Normal file
File diff suppressed because it is too large
Load Diff
7
data/Y24/day1/example.txt
Normal file
7
data/Y24/day1/example.txt
Normal file
@ -0,0 +1,7 @@
|
||||
3 4
|
||||
4 3
|
||||
2 5
|
||||
1 3
|
||||
3 9
|
||||
3 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user