Added AOC 2022 day 03
This commit is contained in:
parent
8fa2813711
commit
6139677289
62
www/statics/aoc/2022/03_challenge.txt
Normal file
62
www/statics/aoc/2022/03_challenge.txt
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
--- 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?
|
||||||
|
|
||||||
|
--- 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?
|
300
www/statics/aoc/2022/03_input.txt
Normal file
300
www/statics/aoc/2022/03_input.txt
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
BdbzzddChsWrRFbzBrszbhWMLNJHLLLLHZtSLglFNZHLJH
|
||||||
|
nnfMwqpQTMffHlNNLllHnZSS
|
||||||
|
cGpcMwfppfqcjcTCBBzWDsDbDrjzWz
|
||||||
|
LhfjhcdjcGdhFfdGfdjdvwCCZMvvLvWwMLCLSwZC
|
||||||
|
rDnsbmptPmlbQMCrQWQQBZQW
|
||||||
|
gltgVPngDPbptPsbPzVgmDldfTdfczThjJJjfMcJdFHjjH
|
||||||
|
dGlgDflTLLLrRLTLVdQLcQMnbvHbbFzNNvMbnHHn
|
||||||
|
sZjWJJCSjWqfCqSjSmJSbFvCzBMBBzHncHNvMBHN
|
||||||
|
twqqwpZwfrlwRwDGDR
|
||||||
|
zCGGFTQMQrsNRNGZdR
|
||||||
|
cLLQgPDpgcgmvPRHrwBdvrNZ
|
||||||
|
glWpmJWQDcJpQnpjSmbhFtMnqFfCVTCFCFFM
|
||||||
|
zNZWFNZBFrGTdBcZZBdJTrGrmgvppgDHwHmgVHCHCvCPDjzC
|
||||||
|
qtqqPnLSfLwvjvvgvvqH
|
||||||
|
MtbLLLQbRfPRfnbnnLMtnsbdBNsrGWNWcNcTBWZrrcrWcJ
|
||||||
|
sZwstbbDVlHtbhcrhhZLrRpNQN
|
||||||
|
jqGjjFjWnzWGgqWjJJNphnLMRhLhcrhcrSLN
|
||||||
|
qCJzFJdvmHvbtpbb
|
||||||
|
ZSRsvvQvZpsRQGJghClPCwGPChCP
|
||||||
|
FVdMLDdtDRdDcBtmcVFntwgJJTlnNPwJnlTlwlTPgN
|
||||||
|
VqttMWFmDbjbzrSWRQ
|
||||||
|
TsDSBcwshdwSCrgRWZBvgGRG
|
||||||
|
LPVJLqqJbbzpFqwpbvgGRmZPrmZgCvCCfr
|
||||||
|
tzJlJzQllFLqtwHhjNSdtthjDhTN
|
||||||
|
fsDLDDnwvnSdqLSsFSDfsLpbgVttPMpPNjMWVMNfpjgW
|
||||||
|
jhHmBmlrTBBHRPVtMZbppNPPZB
|
||||||
|
JmTTrTmjRTJqSQQSFqQw
|
||||||
|
HPzZFgPFMCHJCcZMcDQGwpLqPLqppwhGvv
|
||||||
|
BrWRqbqRsTSTqNddrVrthLQVwnpwphnvnDnGvGDn
|
||||||
|
tSbBfsRbTfqjJqjCqm
|
||||||
|
pCqrqzmqZzrmCCvCJwJPBRwJBWBmwWBJ
|
||||||
|
VqbqbjFLFfSHnfctBwDdDFTwtRRTDF
|
||||||
|
LVcnbjHLSqHnhbSGGppCMMZMphpNrQ
|
||||||
|
PhTcTPsSPCMvvhhMRPttbNWfNsWFNfWWtpNw
|
||||||
|
rdQrDbJBVVjrBVdLjHHHWNWwfHtzzNtFpZZptppg
|
||||||
|
JJVGGdddjDjDJmdjGqqRSbPMTvcRlqnnMlvT
|
||||||
|
SqGfTrBlSrrrfGGQvCnqZhZmPPhvJh
|
||||||
|
LdVNwgsjdjHmjWwDsDpwsHWtnCnQQQQNnvCnbJZQbNbtZZ
|
||||||
|
DjssDHLLVppDssdLspswFLVjzfFMTfSBcTRcrFSBzBTzmGzr
|
||||||
|
JSJJqlldpJlcdVWMlgMJrcCjrhzHCwTjHrQzwTzZ
|
||||||
|
bBvsGBGNFDNRFNFBRDPsDDHCChhhrZRQQzhjhCjTzWCr
|
||||||
|
FvbLFGDDtWDFBnPGFDWGqJMgJpSdVStllttlppVS
|
||||||
|
clpBdBQBsqGpQbVdqTTWRTSFgLLggffg
|
||||||
|
NzvwmHvZtZZgbDSCLDmfmm
|
||||||
|
jPJjthHzNwPvvjwjNzPzztZBlrccpbV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rJMMMCv
|
||||||
|
dWJPngDWBtPVBdPVGHZzCGHZrrvZRSMSzv
|
||||||
|
WDDDVDPlWnLBVgnsgJmQJNqThNmbjlqbbh
|
||||||
|
vnznqvfrzzVzrvvnfVqztBtGbMCdGmCcdccJccCLCcpSSgcL
|
||||||
|
RQsDsljDlhssWshHhlhsHTlLbgJLpmgbbcMSpSSbcSJgjd
|
||||||
|
WswhhHWlRTsQDwWHTRhsvNVvwqzfVmNBtZNmnzzq
|
||||||
|
cjcPfLlQtPsZQlfHZJqVSFdVwmSRRqSSddwDvF
|
||||||
|
MgNbBgzgnwdPRFmSPn
|
||||||
|
CMGbNNMhCMzzPzBpTNPGBclLcLfsptHQfQlZssLcLf
|
||||||
|
slsdfpSlllpTVJJGgGDgHMdV
|
||||||
|
wrBQrbQrhQcpbQrhLwRBrjVVgGGPgZMtZMVhgMPMGHPg
|
||||||
|
QQwRnrwRbbRcmQmrjRnjpvNsNTNSlTmsTqCSvsNSWz
|
||||||
|
GWNwppdHdpmzgPFPCRmlCBPB
|
||||||
|
bSrJhJSsMhrJMDPRCPBlwVCtVSLV
|
||||||
|
QbsbwqQZvrJhhQrhZZrhchTfnTWGNvWpNnjHGvGjNdGT
|
||||||
|
NMZGmnMBWmwmNnGwHrHvHzfrvrVVVj
|
||||||
|
pSbDRLgbpJDPpRZRQjjFqVhhDFjDVqfrzv
|
||||||
|
sQQscLTZcsTpRsBnmlBcdCMBMtlc
|
||||||
|
hwWslbGWbRvLZvcscZ
|
||||||
|
gQnmmrNTmSnTfgwDwVwpJvJPJzLqLJTLLvRcZz
|
||||||
|
mrmnSrDNNQSmmwdggrrDbHMGhtdtGhGlhtClMGhM
|
||||||
|
qQdlGcvDQDQvDdmtPmmmlStbjSrm
|
||||||
|
CpNhzWTCTRznBMvwtTjMrHtSvj
|
||||||
|
nWzsfZCsBhNpZLgGdQDddvqd
|
||||||
|
ggjTjJWDVVVRTwQcZWvchshWhs
|
||||||
|
LmFfLfSmBtCttNLfCFBPFN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TBrrdjFSpFmNBmSfZMwZMJJfSffbwzwPbczbJ
|
||||||
|
QTWSzTTLwTfwflSNJRdvGlRGcNgJBl
|
||||||
|
FnmmqrqbBBgRbHGc
|
||||||
|
MFZqrCVCqmZCprspFZmnnMsDfzWzDwSfjSwPQPTLhffwBLwj
|
||||||
|
npfgFRTZRRnDZLdgRfRrrjcWzGpWGGGQrjjWpP
|
||||||
|
vblVbvSShhVzHWjzzlrPWG
|
||||||
|
bVwqvCBtShqBhCCtqhNqCJRTTBDFJJLnJgDRWFBnWg
|
||||||
|
nHDNQvgvnNZHDnsGcjfNTrTfVrfL
|
||||||
|
SRWFSBRLtSFqjTrVVcsVjTSG
|
||||||
|
BdBbRttWBdbdWdbppmZlLmgwHvgQvgLZ
|
||||||
|
PQRZlpDDptQSclBMGVBdhVFGBMpf
|
||||||
|
nnrsTCWjLJsnsSMShhGJfwffwV
|
||||||
|
vjzqsjqgSHbbtvHZ
|
||||||
|
DgFmbdSDZbPgLbDDmFwZwgLSfccGcGvnvvngsGGnsGMNWsWs
|
||||||
|
HqztHHhHVhHjhRRhJtCVBCfNprMWpcMMJfsvvMsGscpG
|
||||||
|
tjVtBVTBtHHqCRqtzQwTPSNdSwPTTbPFDdml
|
||||||
|
sbmBmHZbRRRmwBmsSjHzRjmSCNFLNLLQNQhFgtQLzNztlrff
|
||||||
|
MpqPPDPVnGqrJpcqqJpMVlgtlLFLChCgChCCQgCtCD
|
||||||
|
VdcVVJvdrVWHbwHWBSSBRb
|
||||||
|
tPDVBzzNSNdDSQpMQMTQJMMQMN
|
||||||
|
LqSWSmbsmfQTTGZMWGCW
|
||||||
|
cLjLcbrjqmvfqLbfmqLwDBBzSHPzlwzcdBlnnP
|
||||||
|
SbnHrGHSrrhHJBrrScDfcPDMfpPGcGcpDL
|
||||||
|
QTpmpmmQWlZsTvVQDMgggFLgFcPf
|
||||||
|
zsCNlltCslzlTNsNlShwdJCpSqdHrBhpwr
|
||||||
|
JZmFrmLGjFZdDGrrVTvzmPVvRRVzwzzl
|
||||||
|
WBnfMDBqMsgDBqpBvzwVlCwRTRRPpvlw
|
||||||
|
WfghfttggfSnnqbDftfqSBBDQdHhZFFJrrHFjGJdGjFrjQLj
|
||||||
|
rNLRjrlVlrFRJzlsjrVlRFGCmnMtftgCNDDgDmCfqNgPNM
|
||||||
|
SpdBpdHbpHWhZqnCdtCGggqCPn
|
||||||
|
QHHvvWwWhwVVQRscVzGl
|
||||||
|
QffLtMQGMQfDMMwMTJwqWHvH
|
||||||
|
nSSFznjFcfjTgVJTJjvT
|
||||||
|
RrBpcfSNpRBcFshrCtQrDGLPQb
|
||||||
|
GctcMldStGwPPbcLsQTV
|
||||||
|
jhnzDgnHnnfPVwHQTTLTds
|
||||||
|
gBgzDDhzvqdGGvrtdvtm
|
||||||
|
PPwRWVTvRvPVLwRpMlzmbmsbHWjbbs
|
||||||
|
dFTFCNfdjzjFjsMF
|
||||||
|
SgdffSTrnnqCgdqgcNrfSZqVvVLRDPJZQwJBLPQPtLZwJJ
|
||||||
|
HSzDQftHphTBHFhr
|
||||||
|
WMmJsMJNLWNPmmsncjMJcjtvwggVvhFFFhjrVwrjrjppvT
|
||||||
|
WWPsJJCWCtZZZRGC
|
||||||
|
SfFZQDRLgpLlRgQRRRFWTsbhBhgTjbWBjhshgw
|
||||||
|
tHVNGjtzzHvMMJJhrWJNrTrPbP
|
||||||
|
jvVVvGCGtCmjHtdHzQQfDpSSlDRnFfQFmR
|
||||||
|
ZBBPfVVPPrVmrWZJzNdPznbnbSzznP
|
||||||
|
gvgpGqFFMgMcGgwLwGpcJNZSTZbdbdzNNSlqbTnn
|
||||||
|
ssZLgsMLQvcFpVrhCsmtWHjrrW
|
||||||
|
nFvhRnWWzBRPHQqcqqCqmFbd
|
||||||
|
SJDJgVprLfDfbJmHmWWHQtJW
|
||||||
|
wVsgWVSTgLjfSsVjVBRvRNwwGGRhNZhRMZ
|
||||||
|
wTRrRBCTPTBPlgMqgHCqggHLgg
|
||||||
|
dmDzpQpBdmWmWzzzDFzjGNMSWLSgLVGGLVNSLgSg
|
||||||
|
JbFdmQQJpjpptQbdJJmDmdtnZhZRflTlnTrTlrhBwPPc
|
||||||
|
jwSwssQbwbStlhRgtsVstn
|
||||||
|
zPzFdFFZccPDgntzVHHgghRz
|
||||||
|
vVVdfFmZPDMWZZBmGQbwJJGCLwwMwJCS
|
||||||
|
PLLffLFqqNLwSffbnVzzRf
|
||||||
|
lsmgTggChrgDtZsZVblMVJMznVnwMBnb
|
||||||
|
hDZZTmZvhTgstvwNFdqpWQcqvP
|
||||||
|
mmWwpwqtmmHTqHpprRZQPPZLZWSFRFRB
|
||||||
|
gzcgscgbfvhRRNZQRRQPvr
|
||||||
|
JsjhcshCfJgrrpttTCTplH
|
||||||
|
TvNrvNrJfWWvtJLTHhvZZhQQwVGZZhbV
|
||||||
|
mFCPmBMPlPsPPBsMFPszbHQJwwHHhbZVQVzjhGHZ
|
||||||
|
qmlBsdCSmJBmsBBMnMMTDWDNcLrDprSNcWDNrW
|
||||||
|
HSnHCVqTddFHSVqFqdStSQGQwRzQCzCRzGRRGNPQwz
|
||||||
|
jhlBpgNvlfZjlfvmpgfgfBrMRRwMMPPLQMZRPMWMMZPQ
|
||||||
|
hflfpgjfBfDcpchlpvndbHFDdHqSqNVqNVdn
|
||||||
|
QBfhlVNfHSZHfVCVHSQfZfTCctdvdDTRtjDCtTRsjsvj
|
||||||
|
brrWWqzFWzwWbswDchhTRtDhjT
|
||||||
|
gbrFLnpzqrWPgqpLWrhnHGZlSfLfHfQBGVfHHNVG
|
||||||
|
hcFmVScmQBVhtcvfHLfvHSnbHRLn
|
||||||
|
lzQqlDqgpWPvJfRnlNJvww
|
||||||
|
PjCCCPgDgqGzmMtCQstZmBFs
|
||||||
|
GrnrHrmVVFMFhSSbSfhR
|
||||||
|
zjTqLtBjjdWdWTLshMZMDbPNRMSSqSPNfD
|
||||||
|
dTWjdtwWhjWTBzcnrpcwmQpCwcpw
|
||||||
|
BgtVBsgVVJhgGsSGJbghJqbsjLfZmLjmmtfZndNNZFFZNLdm
|
||||||
|
MHTlzlwHSvPvzMSPCTMQCNZdjjmnfQjdZfNLjF
|
||||||
|
HMDTwPDpzrTzpScBghDbVqRBgRBJsR
|
||||||
|
qjCsTmrrnnCmhcFrCjqmThRlbHGvJGvvvbRbbJRcQJRG
|
||||||
|
fVBBTfMdSZLNZgPdgglGRdbtbtJRllJWJtWb
|
||||||
|
TSZZSpNMPBLgpZLVgppBDFhzDmjrnzhjssFqDhzFnn
|
||||||
|
MDtDMWmMQmdzmMMqvlGfRcjzgpcPPjczPl
|
||||||
|
sZsHJWNJFJNbWFBhFBnnbVclbVVPglfcRggffGGpjl
|
||||||
|
srHWLNZZJdSLSdvDMw
|
||||||
|
BFqsPnsZcgnncggccqsqqpDPtDWPpPNTNSNThrWtSj
|
||||||
|
dQbfQQJJdwdmFRbJLRJdMrfDWrjpDrrprhDDDDNWWD
|
||||||
|
QGwdJmCFJZvGsvvncB
|
||||||
|
GRRNSjrffGTSPrNTffSgcJTwWJZbbZvwvwtVwWVJZv
|
||||||
|
CMcFsqmBQzMzshsBQBQvLWmJVwZtpJLJwJLvwt
|
||||||
|
qBzChnQlzMcRSnnRRjHGGg
|
||||||
|
dPPbPWNdTBbDpHPHpNsgzvFlglvHzvSFzCFF
|
||||||
|
fntqhGhRMhnnnGGCVMRhCVlSjswFvvjzjSzvQVSgsl
|
||||||
|
MMqqJJRCnMhZLCRhtPNrpZPDDWTDTrNBmD
|
||||||
|
VjVGNTNlNchVjNGRWrSWWtZtRrzncR
|
||||||
|
BTbbbwDmCDLTbDwfHmzZMmRrWtzPrZSZtrrz
|
||||||
|
qDLLqvwLBsfBbBdQFQTJhqThVTQJ
|
||||||
|
qBqPBGZflhrWznzZZdsnzv
|
||||||
|
FmHRcCCsCDwDbjtzdjWbdz
|
||||||
|
cTRwCCNHFNmwRgmFTNCFTJqqfqPJsPhPBlsrsfGf
|
||||||
|
JTNhhNrCTcWpJJcpWw
|
||||||
|
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jgttWBJTLmFLLwdwzFdqLDDDqFGdLFTd
|
||||||
|
RBzRGRGBgnrPJrRGGWWbDggZTSTVZVFFSVZZdw
|
||||||
|
tfmLhjfshNNsqpppfjHdwVdQZbVbQFVVTmSVDV
|
||||||
|
jvqtwHqCNLNsNhNfjssLCzGJWcBRJRBCBBBrrWnGrG
|
||||||
|
cGDBdNFdNdDStNtGdGQGscDMvZjjZWMvMLjsjjLZjLsJLv
|
||||||
|
fbRnRzHVPClfRlbbmfHRlPvZvMLpqjvZJqZMpzMpZjBZ
|
||||||
|
gfbfBgCHCPVNhNGgTtFDcF
|
||||||
|
ljjvLZvvllFnlLJLJjLWFQrVssFpsGMFpNMGsr
|
||||||
|
qbHSqHTcHChqCmTSRqqBVpVdBQsVQQGHdMprWV
|
||||||
|
DbtcCqRhhTRmDnPMlLgfgztlZZ
|
||||||
|
QtMQzPZcbtGgTtLvtf
|
||||||
|
HwcDsdVVDnNSGLhwvffJvfTT
|
||||||
|
CSsdSHNmSDHcCqqcrrzQcC
|
||||||
|
nDNDfmMnmDJRNfJJdMDRBdwjcTtsSHvBTswTjwLtsCts
|
||||||
|
QcbQrZZggGWVVWbZZjStswCSCCttGCwLvC
|
||||||
|
ZgZgbzVglVbchVVrVhFWWpnnpNJmJMqDfMJnMRqNDDMD
|
||||||
|
WMfNvsjWGjsqFjqTRRQVJztDzVmJHbft
|
||||||
|
ZPhplcrLrmzQGzmz
|
||||||
|
ZPddLPlcSclhZChndMvgTjjWNGWMGWBj
|
||||||
|
nDLjMchghDcljfjffpfsqTmGCTGszGZVVzHV
|
||||||
|
wdFJPFrQRwSNbjVQCTGsHZHmHCHs
|
||||||
|
BRJJSddvdBrJwrBRNRFRSPRjvclLpWhpglgWpLplltnMgh
|
||||||
|
BbVRzMcpbMNMHMTJmWdljdlJjT
|
||||||
|
GtsqFnfvGSFqGfQvgnWWZlLlLjZWtWldPmlT
|
||||||
|
sSsFqsqsGghwQQmfGRHbbVczbwwBpBpHcw
|
||||||
|
BBFCBJCsGJBBgvgsvTlVhgNg
|
||||||
|
ZnLdjRQddLRnZrlScHRVTTSHhRvg
|
||||||
|
fnnjZLWdrnqdWrrPLddqVqBzGDJJFGCBDfJmbDzFMbmB
|
30
www/statics/aoc/2022/03_solution-1.nim
Normal file
30
www/statics/aoc/2022/03_solution-1.nim
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import std/strutils
|
||||||
|
import std/sequtils
|
||||||
|
|
||||||
|
proc run03_1(): string =
|
||||||
|
const input = staticRead"../input/day03.txt"
|
||||||
|
|
||||||
|
var res = 0
|
||||||
|
|
||||||
|
for line in splitLines(input):
|
||||||
|
if line == "":
|
||||||
|
continue
|
||||||
|
|
||||||
|
let comp1 = line.substr(0, int(line.len/2))
|
||||||
|
let comp2 = line.substr(int(line.len/2))
|
||||||
|
|
||||||
|
let dup = comp1.toSeq().filter(proc(p: char): bool = comp2.contains(p))[0]
|
||||||
|
let prio = if int(dup) >= int('a'): int(dup) - int('a') + 1 else: int(dup) - int('A') + 27
|
||||||
|
|
||||||
|
#echo dup, " : ", prio
|
||||||
|
|
||||||
|
res += prio
|
||||||
|
|
||||||
|
return intToStr(res)
|
||||||
|
|
||||||
|
|
||||||
|
when not defined(js):
|
||||||
|
echo run03_1()
|
||||||
|
else:
|
||||||
|
proc js_run03_1(): cstring {.exportc.} =
|
||||||
|
return cstring(run03_1())
|
32
www/statics/aoc/2022/03_solution-2.nim
Normal file
32
www/statics/aoc/2022/03_solution-2.nim
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import std/strutils
|
||||||
|
import std/sequtils
|
||||||
|
|
||||||
|
proc run03_2(): string =
|
||||||
|
const input = staticRead"../input/day03.txt"
|
||||||
|
|
||||||
|
var res = 0
|
||||||
|
|
||||||
|
let lines = splitLines(input).filter(proc(p: string): bool = p != "")
|
||||||
|
|
||||||
|
for lineSet in lines.distribute(int(lines.len/3)):
|
||||||
|
|
||||||
|
let line1 = lineSet[0]
|
||||||
|
let line2 = lineSet[1]
|
||||||
|
let line3 = lineSet[2]
|
||||||
|
|
||||||
|
let badge = line1.toSeq().filter(proc(p: char): bool = line2.contains(p) and line3.contains(p))[0]
|
||||||
|
|
||||||
|
let prio = if int(badge) >= int('a'): int(badge) - int('a') + 1 else: int(badge) - int('A') + 27
|
||||||
|
|
||||||
|
# echo badge, " : ", prio
|
||||||
|
|
||||||
|
res += prio
|
||||||
|
|
||||||
|
return intToStr(res)
|
||||||
|
|
||||||
|
|
||||||
|
when not defined(js):
|
||||||
|
echo run03_2()
|
||||||
|
else:
|
||||||
|
proc js_run03_2(): cstring {.exportc.} =
|
||||||
|
return cstring(run03_2())
|
@ -109,5 +109,6 @@ return
|
|||||||
[
|
[
|
||||||
['day' => 1, 'parts' => 2, 'title' => 'Calorie Counting', 'language' => 'nim', 'solutions' => ['66719', '198551'] ],
|
['day' => 1, 'parts' => 2, 'title' => 'Calorie Counting', 'language' => 'nim', 'solutions' => ['66719', '198551'] ],
|
||||||
['day' => 2, 'parts' => 2, 'title' => 'Rock Paper Scissors', 'language' => 'nim', 'solutions' => ['14297', '10498'] ],
|
['day' => 2, 'parts' => 2, 'title' => 'Rock Paper Scissors', 'language' => 'nim', 'solutions' => ['14297', '10498'] ],
|
||||||
|
['day' => 3, 'parts' => 2, 'title' => 'Rucksack Reorganization', 'language' => 'nim', 'solutions' => ['7889', '2825'] ],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user