Skip to content

Commit

Permalink
Day 3 - Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Grenier committed Dec 8, 2022
1 parent 98fe8a7 commit 2c0d3a8
Show file tree
Hide file tree
Showing 2 changed files with 318 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 3/2/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

$rucksacks = explode(PHP_EOL, file_get_contents('./input.txt'));
$priorities = array_flip(array_merge(range('a', 'z'), range('A', 'Z')));
$total = 0;

for ($i = 0; $i < count($rucksacks) / 3; $i++)
{
$commonItem = array_values(array_unique(
array_intersect(
str_split($rucksacks[$i * 3 + 0]),
str_split($rucksacks[$i * 3 + 1]),
str_split($rucksacks[$i * 3 + 2])
)))[0];
$total += $priorities[$commonItem] + 1;
}

print($total);
300 changes: 300 additions & 0 deletions 3/2/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
mjpsHcssDzLTzMsz
tFhbtClRVtbhRCGBFntNTrLhqrwqWMDMTWTqMq
LltbngLGRSBgSgGRCJdSdQHvdfmQccmjSQ
lBslsZDDWdGdGpSMts
grQhDvqLQHDNGJJtbRMQQJ
HChCTnnLCgCrTZPPFzzVPcVD
ShrzjhNGrNqrhWnHHfVHbhnHbbhH
RBsvcBcDCdsRTsvgCgcPFRQpVQGQJPVFbnJfbJ
DvsTsdlCBsGLrjzmlqqz
WJJqZTgCnBLGCZBJCJnTLggTDDSDDMNdDSdbdSSsWDFfMsFf
PVjqpVHmPpvmcjhrRprFmQQffbfNbQMMsSMQNQ
cwcpRvrVlVgwtBwZqBzZ
qfJJmpqpmhsggvvpVPZCrhdFLFzZFDdLLh
CtCTBctGcGLSzZddGZSW
RlNjBCnjttBHHMMcQHCsRfsbfwgggmmJvmgfpm
ZmcgBBZhZMsnqnCPjpHPjLHp
dGbNwNtlTMTzGfNvTvdwNGVLPpQHPjLQPCpCjPqjLbpLPR
dvDTdfvNBhDZMBDZ
cvvRvbqcllbBVlvVVbV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