Day 3
This commit is contained in:
parent
f9a1e4f2d4
commit
13f84a3296
@ -1,4 +1,4 @@
|
|||||||
with import ../utilities.nix;
|
with import ../util.nix;
|
||||||
|
|
||||||
let
|
let
|
||||||
input = readFile ./input;
|
input = readFile ./input;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ../utilities.nix;
|
with import ../util.nix;
|
||||||
|
|
||||||
let
|
let
|
||||||
# read file
|
# read file
|
||||||
|
300
3/input
Normal file
300
3/input
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
dWlhclDHdFvDCCDfFq
|
||||||
|
mGdZBZBwRGjZMFgvTvgtvv
|
||||||
|
jwwJrzdzGdSbGGnNlzWczHzPHPhn
|
||||||
|
cczcbMBszhzzDBTBPPPGjtvtlt
|
||||||
|
LqJLfpwdLnvQLRGQjGtj
|
||||||
|
gSgnSJJCGSGpGSrwgfhchmmmHzcrHDmbrmMm
|
||||||
|
bVjstCsSstCLCrbSLnMpdMndcLddcqcpHR
|
||||||
|
wPZJQJwtBfJZmgBwPTcpTdcnfHMppcGMdG
|
||||||
|
gmFJzwPJJtszvNhCNC
|
||||||
|
DmjZDMZWDqGRqqRpHmmRLTTNTPTfCQJQQLJHTClc
|
||||||
|
FtzfvrfFwVgtzztgBLJNcNlTcTVNNQLN
|
||||||
|
vgsdbzzrwtqWfWRpZDdZ
|
||||||
|
rJhqRhLHhdcQqdHqfQGfPGstgGPlWttM
|
||||||
|
DzCpDDmnNCmBZBZnVBmZzBGPfsbglfNPwgPGPMWsWWft
|
||||||
|
BZFnlmpBpBzDzVZmhFHFrrrchhRqTdrc
|
||||||
|
DWCCWFNqdGFdPVcb
|
||||||
|
HllttQsTRlJlsblrHlhdmPLVcVcTccndLvPLmL
|
||||||
|
HSlstHgJltghhRrzNBNDzSwMjNZwNb
|
||||||
|
dzGSHCWSsGVVSdHVHHWWVVDCgJDpQqLTTRJpgmTLRmJTTpTR
|
||||||
|
BvNjMPZMBtBBMvvNMNttlhLQqCJpLmhTRQq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TFFmRRRNjZd
|
||||||
|
qbWVfChDCDnVVDGfnSFNNjRLmNfBNLQjLjmBRm
|
||||||
|
DhFDhbnWCDhGcbJPPwrsrMwrvlvc
|
||||||
|
lFSDTwHTSwlTNwFFlwNcFFpjLZvZqvnqLPnnWbgngbbncqbZ
|
||||||
|
rzQfMzRGrRGJCffBMGdGsJZWWnqWVqdPPgNvvVZWPWWn
|
||||||
|
RJrttBtNQCsNzTpShhHFDwFlth
|
||||||
|
QNzQFjNFrQPNbmPpqTTDGswWmB
|
||||||
|
ggHRcSlcCVCSzMVqDGwgqTWpsmqwqG
|
||||||
|
cltzCZtLClHRRtMZZLQjfNvtrJfhvrddvNNd
|
||||||
|
mcfWHffBFnQRQlTFdv
|
||||||
|
wssSLVbbzDVbzbggzSzNshNMnvnljRdvQRlMBjvQdnCj
|
||||||
|
bhDzVSSJDDJhDLBwtbDzzbbWppfpcmWGmprqqGtqprcHPp
|
||||||
|
rpVFrZpgHWSZrFPqhzwcqPwmcVBD
|
||||||
|
vMTnQJjQLCbljvvQzTMbTjPNdBLwwDhmhNNqPwmmhhBh
|
||||||
|
jvGjjQJnrspGHgFz
|
||||||
|
sjssjtZlcphZHwWvcrHTwWJH
|
||||||
|
qDdzzrFNNNDGdFDzzVBVVvfWJPfgPmgWPgvwVH
|
||||||
|
nqMQGDrnLGnqqLNqjtCZZjsMhZhCMbtl
|
||||||
|
JJJsLFmzsrFlSpzPscjgHhnRnmvcjqRvvj
|
||||||
|
fCMQbCbTjjqTGhjc
|
||||||
|
bfdbWdCddfBbtCfbfbqVWQQpPlBrJLJJSSLwppFssFzLzp
|
||||||
|
pdbbzlffWtJbgQwhcphQcCCg
|
||||||
|
vHvLFvVLvSfFRLnRFRNHjPjggcssQcjjsnwhsPCC
|
||||||
|
vGVGGFFVHLTvDRHDmBbTzfZWMdJZlfMm
|
||||||
|
wjCbjQgjTQhNNzgWQCWrDFMZmZDZDCrrMDpLpL
|
||||||
|
czGSPznnRGGJGGlVVRVBGGlB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wrMJcVbWfSPPWpmpjmSCF
|
||||||
|
jHVjjCcpNrDgjsfB
|
||||||
|
ndqllRvJQtqlQQTRWllFNDrsMZBfDBLvNMNDfsbZ
|
||||||
|
qTFnWJqdWRdqWRlnTRnQGnTmwwSHCzpcGNmHNcPVcHGmCz
|
||||||
|
pZCpBhDfvgBVZQGMMVZVlq
|
||||||
|
sLsLTTSssjPnTNbFGRGFPVHqMMRF
|
||||||
|
TsNSccnjLdcsLjdmjWvWvBhfmvWpCGhGhD
|
||||||
|
VWFFFPMpPVSMbTppHTnHTbRH
|
||||||
|
DtvfNdBNddDNSLjsvDTTHnzzHwrTrwsrwqbT
|
||||||
|
dgBLNffdgjjtfBQSvgNjNDlvMcQJmJJmZCMmVVVZFPFcPMGG
|
||||||
|
VWsQLHMVVSNRShWLhNSNLjbbbddbpDZDddcbZdDRztpd
|
||||||
|
FPlhhgPvThGFJndnnCCnJzzdCp
|
||||||
|
qrTfmllGvfvGqwNMMMsffsQsNh
|
||||||
|
NsmFqNlmnQRbCFsmJgSffpPcbvSfrVvpgS
|
||||||
|
LhZGDZhhwtDHMwDdHGhDjDpTzzPdzgTvcPvpSSpPrdrv
|
||||||
|
jgHMjBLhwtZMHMHmJNNJNFlBqlBJNn
|
||||||
|
bznSQggscgMcSTTfJbSQzQFwClMhmCmthClvMwFLwhZL
|
||||||
|
BRWBPBVVPjPNVHpVqlqrvtwFqmmLqltZmL
|
||||||
|
WDVddNHNvRgccgsDsgbT
|
||||||
|
sNgnQLtLLLPPnsPpqdqjBclpGWjcWjBG
|
||||||
|
rVCChSZhVrrwqVDVHSHmMjldGfJGfHddJGJlfGjGJj
|
||||||
|
CVZmDvZCmmhFVVrCgTNbbnQFgbsqNqNQ
|
||||||
|
WmMmSSfJNRRPfJRMRMtllCgdStgbgttgCdDd
|
||||||
|
QGBrvzwBczlgqCtDbvDq
|
||||||
|
QQpBGFrLQjQzGVVRNjPmNNWMbW
|
||||||
|
gGljnJhnJtllpNVCHWcccdTdjdmB
|
||||||
|
bLfSQDSMSHmBnwCB
|
||||||
|
LFMDrbFfFQZQRzLZnbgtlsRGtltpgNhgPpPG
|
||||||
|
cRThZZchCThtgTRhZTRtjWFjWNwqCjGmwFjqqffC
|
||||||
|
DPDPGzPMHDbrpqjfwrjqmjmp
|
||||||
|
JVHHDdVdVbvGMdnVdQVdDbHcRZllhRtgStRLThRSTcBTvc
|
||||||
|
lQWPSBrrPZGgPglGssDfHnWsfDFHHvHh
|
||||||
|
TDCqpttptJNLtwNpbwTqzqHshsvsMMFnmHMNfssmvmvf
|
||||||
|
JCjqVpDtrBjQjrlj
|
||||||
|
wFGWGpFLvCczNSWWsz
|
||||||
|
tlfgtftjlbtHHlDBsBzmQQnsQDQsCn
|
||||||
|
gjfrsVqVgPlfqhvLdvdwZhGq
|
||||||
|
pHpZHBSvRvRCBBZCTMngRnWndnRmWcgg
|
||||||
|
jsfrfrjJFDwDDMMggMCGWGcfmG
|
||||||
|
qbCszCjtCjQsQrtZVBHBHvBvqLZvlp
|
||||||
|
scFzsPScNgNPNgQzpttlCBCwpLrMLCrDdljLwq
|
||||||
|
TjfGZZjVwMZwMLwr
|
||||||
|
vnGbWTvTmFRjQFQPsb
|
||||||
|
bVLrzqrzJVgJbbtVrWJVgppcBCzBvdzwBCCBHDcBvc
|
||||||
|
hflPQnMQmQSRlQMPNRTHwwHHHqpHpdfwdBCp
|
||||||
|
hFhZMhqSNMNbrZgWWGWJjZ
|
||||||
|
NJsgNjJlMHQrwnRgSRPwrP
|
||||||
|
tqpQtTFpFvbGpzTTWSrnSbrhwChCnRfrCf
|
||||||
|
GtcvGqQpttzcqdFzWppDsZMJjBBsBJcBNmBjMsLJ
|
||||||
|
lGfZGZhFfhdSWqmFFWSS
|
||||||
|
wDRDPLcDnjtWbSmqrSCSLC
|
||||||
|
MPwmtVnVMjztznHPgQhQfJfvvHHGggQZ
|
||||||
|
llTspLllCHmLHHndldqHdlLQQPSBQczZSFDDQZSNGcGG
|
||||||
|
jMhwvVrRjbRhFBZNGPcGNN
|
||||||
|
wVtrrtRwrfrwftjVjwWvMrRpsqsnsHsBglslCmTsdWdHTd
|
||||||
|
vPvmTGgDPRvGpDPGPqGHQnWJQJMBBzJBlBQWlHWl
|
||||||
|
bfbwNsmwFdLjbfrrLsSfLNQtMllznBzJQZMQtMlZZnnF
|
||||||
|
frssSscssNfScCjfSCwjsDmRDpGmDRDvvvVcvRDvRp
|
||||||
|
LtlPZPjBTbWsWJVJVzdT
|
||||||
|
nnprqhrqmzfrSrphqfCChVVGVDJWgSHHWgWsRDVHWd
|
||||||
|
nrmppNqhcCrfMchcMCncqbzPZvlvlwbBNjPjtNjZjL
|
||||||
|
FPWsFdSspVbbbtWVvl
|
||||||
|
CCHnnfHHvCwtVMhzlzDllC
|
||||||
|
LrGnjGfgfvcwfgrLrBjrBLgwdBTSRBFsRZdRsSqFFSFSSPPp
|
||||||
|
whGCLqsrjgGhhGFqrCCFGCGzTRTZJcNnzlLTnznNHcnzTH
|
||||||
|
ddvVmbfvdvVbDVQdvvdSzpNcnJzlzSRHNJpnJcSc
|
||||||
|
BPdvfQdWtPDDPfDvDQVVPmbhssCGGMqgFCFMqGMWgMjrRw
|
||||||
|
PSLbGmWPSPLQbMTPWGFWltthdDdrmBDHhdDdczzDRh
|
||||||
|
VfCngVfgsZwCftrZdhcZrdNDzz
|
||||||
|
CjVJJJqnJwQhWPPLQlGj
|
||||||
|
ntnnQmTQTQGVWGNGNNlClG
|
||||||
|
jDffjMSvqjHzHHzwNVwNVcCddPVNdD
|
||||||
|
ZszJsrrZMjsHqqvZJLRQCbTRQbJmThbt
|
||||||
|
BgLHgFDsJNWgQgflWd
|
||||||
|
mnVVcCHnCGRcVnZSjmlthftMQddlfhQctNfW
|
||||||
|
qbSGqmHSTFprvpvTTL
|
||||||
|
dvdTMvvpdLpTcSLvdLLMmhfFBftwCNhRwRNjtCTRCf
|
||||||
|
lshQWgsgrHHqlFfRqFjRFfFwCB
|
||||||
|
rsgHQbJbrsGHHlgQHgJrlHrPZdhdpMZGDSDpdPLcZhdvhZ
|
65
3/puzzle.txt
Normal file
65
3/puzzle.txt
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
--- Day 3: Rucksack Reorganization ---
|
||||||
|
|
||||||
|
One Elf has the important job of loading all of the rucksacks with supplies for the jungle journey. Unfortunately, that Elf didn't quite follow the packing instructions, and so a few items now need to be rearranged.
|
||||||
|
|
||||||
|
Each rucksack has two large compartments. All items of a given type are meant to go into exactly one of the two compartments. The Elf that did the packing failed to follow this rule for exactly one item type per rucksack.
|
||||||
|
|
||||||
|
The Elves have made a list of all of the items currently in each rucksack (your puzzle input), but they need your help finding the errors. Every item type is identified by a single lowercase or uppercase letter (that is, a and A refer to different types of items).
|
||||||
|
|
||||||
|
The list of items for each rucksack is given as characters all on a single line. A given rucksack always has the same number of items in each of its two compartments, so the first half of the characters represent items in the first compartment, while the second half of the characters represent items in the second compartment.
|
||||||
|
|
||||||
|
For example, suppose you have the following list of contents from six rucksacks:
|
||||||
|
|
||||||
|
vJrwpWtwJgWrhcsFMMfFFhFp
|
||||||
|
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
|
||||||
|
PmmdzqPrVvPwwTWBwg
|
||||||
|
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
||||||
|
ttgJtRGJQctTZtZT
|
||||||
|
CrZsJsPPZsGzwwsLwLmpwMDw
|
||||||
|
|
||||||
|
The first rucksack contains the items vJrwpWtwJgWrhcsFMMfFFhFp, which means its first compartment contains the items vJrwpWtwJgWr, while the second compartment contains the items hcsFMMfFFhFp. The only item type that appears in both compartments is lowercase p.
|
||||||
|
The second rucksack's compartments contain jqHRNqRjqzjGDLGL and rsFMfFZSrLrFZsSL. The only item type that appears in both compartments is uppercase L.
|
||||||
|
The third rucksack's compartments contain PmmdzqPrV and vPwwTWBwg; the only common item type is uppercase P.
|
||||||
|
The fourth rucksack's compartments only share item type v.
|
||||||
|
The fifth rucksack's compartments only share item type t.
|
||||||
|
The sixth rucksack's compartments only share item type s.
|
||||||
|
|
||||||
|
To help prioritize item rearrangement, every item type can be converted to a priority:
|
||||||
|
|
||||||
|
Lowercase item types a through z have priorities 1 through 26.
|
||||||
|
Uppercase item types A through Z have priorities 27 through 52.
|
||||||
|
|
||||||
|
In the above example, the priority of the item type that appears in both compartments of each rucksack is 16 (p), 38 (L), 42 (P), 22 (v), 20 (t), and 19 (s); the sum of these is 157.
|
||||||
|
|
||||||
|
Find the item type that appears in both compartments of each rucksack. What is the sum of the priorities of those item types?
|
||||||
|
|
||||||
|
Your puzzle answer was 8105.
|
||||||
|
--- Part Two ---
|
||||||
|
|
||||||
|
As you finish identifying the misplaced items, the Elves come to you with another issue.
|
||||||
|
|
||||||
|
For safety, the Elves are divided into groups of three. Every Elf carries a badge that identifies their group. For efficiency, within each group of three Elves, the badge is the only item type carried by all three Elves. That is, if a group's badge is item type B, then all three Elves will have item type B somewhere in their rucksack, and at most two of the Elves will be carrying any other item type.
|
||||||
|
|
||||||
|
The problem is that someone forgot to put this year's updated authenticity sticker on the badges. All of the badges need to be pulled out of the rucksacks so the new authenticity stickers can be attached.
|
||||||
|
|
||||||
|
Additionally, nobody wrote down which item type corresponds to each group's badges. The only way to tell which item type is the right one is by finding the one item type that is common between all three Elves in each group.
|
||||||
|
|
||||||
|
Every set of three lines in your list corresponds to a single group, but each group can have a different badge item type. So, in the above example, the first group's rucksacks are the first three lines:
|
||||||
|
|
||||||
|
vJrwpWtwJgWrhcsFMMfFFhFp
|
||||||
|
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
|
||||||
|
PmmdzqPrVvPwwTWBwg
|
||||||
|
|
||||||
|
And the second group's rucksacks are the next three lines:
|
||||||
|
|
||||||
|
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
||||||
|
ttgJtRGJQctTZtZT
|
||||||
|
CrZsJsPPZsGzwwsLwLmpwMDw
|
||||||
|
|
||||||
|
In the first group, the only item type that appears in all three rucksacks is lowercase r; this must be their badges. In the second group, their badge item type must be Z.
|
||||||
|
|
||||||
|
Priorities for these items must still be found to organize the sticker attachment efforts: here, they are 18 (r) for the first group and 52 (Z) for the second group. The sum of these is 70.
|
||||||
|
|
||||||
|
Find the item type that corresponds to the badges of each three-Elf group. What is the sum of the priorities of those item types?
|
||||||
|
|
||||||
|
Your puzzle answer was 2363.
|
28
3/solution.nix
Normal file
28
3/solution.nix
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
with import ../util.nix;
|
||||||
|
|
||||||
|
let
|
||||||
|
# read input
|
||||||
|
input = readFile ./input;
|
||||||
|
bags = map (line: toPriority (stringToCharacters line)) (splitString "\n" input);
|
||||||
|
|
||||||
|
# converts item symbol to numerical priority
|
||||||
|
toPriority = l: map (c:
|
||||||
|
if c == toLower c then (charToInt c) - (charToInt "a") + 1
|
||||||
|
else (charToInt c) - (charToInt "A") + 27
|
||||||
|
) l;
|
||||||
|
|
||||||
|
# split bags into their two compartments
|
||||||
|
compartments = map (contents: cutInHalf contents) bags;
|
||||||
|
|
||||||
|
# find the item in common for the input bags/compartments
|
||||||
|
findCommonItem = l: head (intersectManyLists l);
|
||||||
|
|
||||||
|
# common items between the compartments per bag
|
||||||
|
commonItems = map findCommonItem compartments;
|
||||||
|
|
||||||
|
# common items between the bags per group of three elfs
|
||||||
|
commonItemsInElfGrp = map findCommonItem (chunksOf 3 bags);
|
||||||
|
in {
|
||||||
|
part1 = sum commonItems;
|
||||||
|
part2 = sum commonItemsInElfGrp;
|
||||||
|
}
|
32
util.nix
Normal file
32
util.nix
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
let
|
||||||
|
lib = import <nixpkgs/lib>;
|
||||||
|
utils = rec {
|
||||||
|
inherit lib;
|
||||||
|
# Passthrough trace for debugging
|
||||||
|
pTrace = v: lib.traceSeq v v;
|
||||||
|
# find the total sum of a int list
|
||||||
|
sum = l: lib.foldr (x: y: x + y) 0 l;
|
||||||
|
# splits a list of length two into two params then they're passed to a func
|
||||||
|
split = pair: f: f (lib.head pair) (lib.last pair);
|
||||||
|
# Finds the max value in a list
|
||||||
|
maxList = l: lib.foldr lib.max 0 l;
|
||||||
|
# Sorts a int list. Greatest value first
|
||||||
|
sortList = l: lib.sort (x: y: x > y) l;
|
||||||
|
# Returns the top cnt items of the list
|
||||||
|
topOfList = l: cnt: lib.take cnt l;
|
||||||
|
# Cuts a list in half and returns the two parts in a list
|
||||||
|
cutInHalf = l: [(lib.take (lib.length l / 2) l) (lib.drop (lib.length l / 2) l)];
|
||||||
|
# Splits a list into a list of lists with length cnt
|
||||||
|
chunksOf = cnt: l:
|
||||||
|
if lib.length l >= cnt then
|
||||||
|
[(lib.take cnt l)] ++ chunksOf cnt (lib.drop cnt l)
|
||||||
|
else [];
|
||||||
|
# same as intersectLists but takes an array of lists to intersect instead of just two
|
||||||
|
intersectManyLists = l:
|
||||||
|
if lib.length l == 0 then []
|
||||||
|
else if lib.length l == 1 then lib.head l
|
||||||
|
else lib.intersectLists (lib.head l) (intersectManyLists (lib.tail l));
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib // lib.strings // builtins // utils
|
@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
let
|
|
||||||
lib = import <nixpkgs/lib>;
|
|
||||||
utils = rec {
|
|
||||||
# Passthrough trace for debugging
|
|
||||||
pTrace = v: lib.traceSeq v v;
|
|
||||||
# find the total sum of a int list
|
|
||||||
sum = l: lib.foldr (x: y: x + y) 0 l;
|
|
||||||
# splits a list of length two into two params then they're passed to a func
|
|
||||||
split = pair: f: f (lib.head pair) (lib.last pair);
|
|
||||||
# Finds the max value in a list
|
|
||||||
maxList = l: lib.foldr lib.max 0 l;
|
|
||||||
# Sorts a int list. Greatest value first
|
|
||||||
sortList = l: lib.sort (x: y: x > y) l;
|
|
||||||
# Returns the top cnt items of the list
|
|
||||||
topOfList = l: cnt: lib.take cnt l;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib // lib.strings // builtins // utils
|
|
Loading…
x
Reference in New Issue
Block a user