Day 3 Part 2
This commit is contained in:
parent
d579a0e8e9
commit
9c43a0f50e
4 changed files with 360 additions and 23 deletions
|
@ -72,20 +72,24 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn example_sequence_parsed() {
|
fn example_sequence_parsed() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ok(("", vec![
|
Ok((
|
||||||
Trick {
|
"",
|
||||||
against: Hand::Rock,
|
vec![
|
||||||
thrown: Hand::Rock,
|
Trick {
|
||||||
},
|
against: Hand::Rock,
|
||||||
Trick {
|
thrown: Hand::Rock,
|
||||||
against: Hand::Paper,
|
},
|
||||||
thrown: Hand::Rock,
|
Trick {
|
||||||
},
|
against: Hand::Paper,
|
||||||
Trick {
|
thrown: Hand::Rock,
|
||||||
against: Hand::Scissors,
|
},
|
||||||
thrown: Hand::Rock,
|
Trick {
|
||||||
}
|
against: Hand::Scissors,
|
||||||
])), sequence_parser("A Y\nB X\nC Z")
|
thrown: Hand::Rock,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)),
|
||||||
|
sequence_parser("A Y\nB X\nC Z")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,8 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
chunk_iter = "0.1.5"
|
||||||
common = {path = '../common'}
|
common = {path = '../common'}
|
||||||
|
intersection = "1.0.0"
|
||||||
|
itertools = "0.10.5"
|
||||||
phf = { version = "0.11.1", features = ["macros"] }
|
phf = { version = "0.11.1", features = ["macros"] }
|
||||||
|
|
300
day_03/input/part1
Normal file
300
day_03/input/part1
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
PnJJfVPBcfVnnPnBFFcggttrtgCrjDtSjzSS
|
||||||
|
llWlLbmmdLLwLbqGdmTmbZfCQtzrMQfrjSzrtSrMqgMt
|
||||||
|
sHlZTsWZwGGlZmGTmdlZbhJNRPphVfRvVnRBsRsJJV
|
||||||
|
fsHtVbjtqstBghhwwPBw
|
||||||
|
SDQzzSzQrQMmmQlmlcNcJLZPgLrVZTdCddhgdPwwCw
|
||||||
|
JmSWSVGGlJJbRsbpWHfbRj
|
||||||
|
tJndRtwtddPvllvfrldrfPpHWDgglFDWWmMmHWmHpZlS
|
||||||
|
BBJTTjCsJWZCmSHSZD
|
||||||
|
LhqLcVzshTNjhqhcjLLTLjbTnGndfdwrfPRVRrdnwftQwJRv
|
||||||
|
wHlPJZwbbZfqbFwqFZfrrcrJrtMWSMMVtVcJht
|
||||||
|
NzzzNBjNfLzvGfDNjMhVhrrMShLchsRVLs
|
||||||
|
DDdmmgBGDNdgfgZggnZbZHln
|
||||||
|
jqNjZJqsGsRqJJqnlJJGzMzffcffTCfQcFmvcWfvTNfcvv
|
||||||
|
PdhVdrwphhVtDdSPLmFCWTLFWWTfFQQr
|
||||||
|
dSPwbbVdbpQllZMQbMjM
|
||||||
|
QQdfflqvjTvfZqLMWfNDGhwsCNGGGM
|
||||||
|
rzRRRTVTPTNhsDWDRhGC
|
||||||
|
gHSTpTnppvjQgJjcql
|
||||||
|
nzNvsFBBBFsNrnNBrvndfThwDbhVPzVVwhZZChpZPCbZ
|
||||||
|
GMQQStmcHHmlfMtPwbZVVVVhhPhbVc
|
||||||
|
GmSmMGlmWWgqQMHgQHtSvTNTTrgBBvNvFsfTfLvd
|
||||||
|
VNVBgRRBRzWRRbRTrTBgbzpZvMvMJlQJZJpJvlTMdJlp
|
||||||
|
mfdfdfdHfQplZJJh
|
||||||
|
ttnPmsLHmqsPGgWjjWRbBdbbGj
|
||||||
|
mMMzwFFpnwgMggSzhQSbSJbhWzbr
|
||||||
|
NPRlHHPbPRdPHCdRNGWWhWQhJVVGhZrCCJ
|
||||||
|
LlNbRllLLdHnpLgMTgTsDT
|
||||||
|
mWhvwmthrzJrLhvftwPrtNHlbcHgbDzNDHcGgzllHl
|
||||||
|
TCjdSCFMQCCCjMspCMQBMqpFHNGblPPnGNNbpnpccZGccclc
|
||||||
|
jVBPsqdFMFsTVMsdMmfwhwvVwLrvWhVtJR
|
||||||
|
TdhJJttgmdgctBBhBwBqBCLWqC
|
||||||
|
fjNGPblpPlRDfsfGbfcWqBqwWvnHVvBLVHss
|
||||||
|
lpRNDGjbrGfPZbmZZMFdTzTgcFdS
|
||||||
|
WPLMvWLMqLcSvrrBmDPFfRzmDPRfZDHP
|
||||||
|
dCggNCCdNCbHTHTfFnNHzM
|
||||||
|
GlJVQjdCCwjMGbGpjGdCpqrtctqcttchsrLLcthlhc
|
||||||
|
jgPHPgjGCwrqjqrvzBfFfCTTCdFpDD
|
||||||
|
QhQLtcrQQLWshQttdzzvzBnhvvBhvFTv
|
||||||
|
RJRssrQSWQSqjqqVSSGP
|
||||||
|
sPszmnmnQPQbjSRVVjbRjVVB
|
||||||
|
cdvZqMfNchMMMqCBlBZlmSmWCHBj
|
||||||
|
dFFDqJNNJvTJTqvvwmGQsGwJztgrwsts
|
||||||
|
dJGPMNStSclWJSPScMNMzqqDfzqVzwwjGfzjqfQz
|
||||||
|
hppFbrhFrrhgCpFlFhvFTgrsDfsjVzvLDfqwVzzwQDsVwL
|
||||||
|
RrgnZbphTpbgrnZgmpbhFcMlnWdMBNWJdtNJBMMSMc
|
||||||
|
HqtfLZCLmLtrSqZStzFtwpPQWlNQBpplpQWmBpNp
|
||||||
|
jMJcnRFcJjvjvcGvdJpBppBwQBpwQWPW
|
||||||
|
DcvDgbhjMMsjGvcjRRvjvgbGtsTZFHCCHSCHZHLfsSsCSrZH
|
||||||
|
wvFPFqvjlgTwjvjZbMSzHTSScMBBbN
|
||||||
|
VVmpVsmmptfDsdSZbMzZzMZBtB
|
||||||
|
LVhfGJVhQsWhVJhfmGJMwljFvqWrlPvCqrqjFFvj
|
||||||
|
cdNbtwrtwrRNLzhQhHfCzbGzQH
|
||||||
|
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bTgtLmrblPzShhRpvRPZPVz
|
||||||
|
tWbqHlHmWHgWHtqrLJJsvBwnBfjswjwnNMwf
|
||||||
|
qQfdCVqZSqZmQmgVqCqCWTMcNFTwWwTccgpcWcpw
|
||||||
|
nSLrjrJnLcTwLNcz
|
||||||
|
sjRjSnJnRsBlPtnqCqCGfCbmQGHfCl
|
||||||
|
tqSmNPNcVrNNmPtHfMZbCWMCZbHwfdzW
|
||||||
|
RwgGvFwFdsssgjdb
|
||||||
|
LnLhhnFDStLJSrtw
|
||||||
|
HHGCHgfjgjgzNSTgJTDJ
|
||||||
|
WdMbDBdQLLZPWZVZZmLdzqqNbvzswSzrqqsJwSNw
|
||||||
|
QQmQBmWQZBmRPGfRjRcHccplpD
|
||||||
|
zFpjDvzDzWWvWBqDqvQcjsfbHPjHsVjcPGffGc
|
||||||
|
TttwldmlTPSCCZmhlNggwffhHsshRsGssRsfGHRhHf
|
||||||
|
twmMMmltZdNNlZLLMrPWzrrprpDr
|
||||||
|
ChCnpqhzCdndsDCnVpVJBgLTpTtgVggL
|
||||||
|
swHPGmwHbjPjvjQsGLSgVMtgSLLTVBHSrg
|
||||||
|
mRPPwvbvbvQjljvbPvPlfwWhsnhZDzFnWhDFdWcdhZWl
|
||||||
|
ndnSZSfNgmmSZlbllglVVsBCfqFBfttpPFtsqV
|
||||||
|
DJwcMzJDwLcMHMDRMRrtVWFWtCBqBWpWCzzP
|
||||||
|
wvcHhRcTJJvTRLRvRhwTQTHdQjqqGdgnbGQgSbqSbgNSdl
|
||||||
|
MHtvCFtCFvMvBDcVfjhhQf
|
||||||
|
WJZWSgZbdlwZZsbTbwDhcBVQhmTTTcfRjmjD
|
||||||
|
WwwrBwZsSJWwFttnLrMCpntn
|
||||||
|
BJgWJVSPVzNJNPZPVHBJHBfdhbjDnbQndnBnBQfndQ
|
||||||
|
MwMsNmNpmsrrwLssvsvpRpvQnCqbCCQfCfhhbDnqCfqLqn
|
||||||
|
MFvtrmGMFwRmFvcvMFmsWSVHWVHNzgZWTtWSTPSZ
|
||||||
|
wWNsHswfsWnVvNZvMLDRRpcLMBDnBlpR
|
||||||
|
QFdhqzFbzmgbhzQhFSLRrpBBBRcRBcLldpWc
|
||||||
|
SbmhzChGhqgQFFzqGJhwvtvNWCtVjVfwwZjHjT
|
||||||
|
WHGDHBRQHDBBQpGzBzQlDVjPmmVtbqbLmtPtzvmZbb
|
||||||
|
nchMhdMgCMJcwvLZvVcffjZfmq
|
||||||
|
ndhghggCwSnhCnnTNSdBpFWQFNLFlpHQpDLRGl
|
||||||
|
FZdjbqjjZTFbRHfVwgttfBZrBpBB
|
||||||
|
LJQFJWhPPnQJJQCPQpzwphczchrgtrfBrf
|
||||||
|
FFWvnlLGDGRMDHjm
|
||||||
|
jCsCNZTTfjcQMLWTtvHQvG
|
||||||
|
mgwdznllpRgBgpBDdnDDzBDmdrMHMLjtvvHJtLrWrHQWvQtv
|
||||||
|
lgjDpVSppmqsqssVPZPf
|
||||||
|
NcNwtChhScfPtwVRgmvWvWvNllVg
|
||||||
|
nZGJMJLnqqGzLzrGQvlmmgrTmWWlcVvR
|
||||||
|
LLdMzdssLZnMMbbZBJGsqLcjwjwPffpdtjFpFhPdFwjFFD
|
||||||
|
wQvZHfbLjrMZSVWMZSdZ
|
||||||
|
wwqhwtTRRpCCMmsnVlWGMpWM
|
||||||
|
qBDcqBTBtJCBDqctRDCBCzDFLfbfLwvfbQcFHNvLvvfQjQ
|
||||||
|
QDFwwvLJFjWQvWgGNnfNftCJPggP
|
||||||
|
lpqdpqqrqBBpTTBsprpsTsbrNGPfCPzftfPMMGztfzNgNflM
|
||||||
|
sqdpHrcbmTTHTdcspZNbZmDSQLQjhhSSWwvWWFHQvLLh
|
||||||
|
gjQHjfqgVSqjqMSnCRMDMvCGZDvCNCNJ
|
||||||
|
FnLswmdphJchhcZd
|
||||||
|
bslwFmLTTbWWmlmbBLwlpBHPPBjqHjBSgPSSSfrVnzqQ
|
||||||
|
JddrdBgJpChGfDLDDpcm
|
||||||
|
WnSFqRhnjjWSSlSFWqTFVSLGbDLcbLDDvDLztbftVzcv
|
||||||
|
nRWjsRjQFnQRshgwJCZwJrhw
|
||||||
|
rnbZwrcZQdpsLpHDVWBBBgDv
|
||||||
|
NNTSFCqJFMMMSJqTFFPttmNPlwgLvWvgWBffWlClLfvlVCVv
|
||||||
|
TMTTJSJFRNwmjZsnGsrhnZZR
|
||||||
|
CMZhZstZqlClJScfBrfHHHFWFFHh
|
||||||
|
RwGdpjdGVGdmNHcfczpJWWpf
|
||||||
|
dDJnQbdnwQdbggSPgPsnlqSn
|
||||||
|
hnczBfznJFmzhnzJLLMwLjmQrppgCjqC
|
||||||
|
HRRlrPRZSDtQjjPQNMPpPw
|
||||||
|
ttlZHDRGRlRtGltTtGvcbnFrbvWJhvWhndcFWF
|
||||||
|
hRsCqfRdqdqfqdtqmMmmZpStMTZZSTnp
|
||||||
|
VjDDjWbzPFFwPRPFDjzLSnTMnZSGZMnWpLLmpL
|
||||||
|
PVHFNBzDRbDwzjNNzHdvdHvlhhcHgvCglf
|
||||||
|
cRLLzhRBhLhVLLLMnnRVVhtJgNgPJmPgPvDPJgvzvvNJJP
|
||||||
|
lpFffHHWHbbMNPQgsgJJmW
|
||||||
|
lpdplSpHSHlCCTbSpSFwdnLqMwcdBRRRLdRnth
|
||||||
|
csZWwFFZbtbztcZttbnRbGlbJhqfnhlpnn
|
||||||
|
mmTjjBLdSMQdBggQHNgTmjgJJRqRhCJphRHRRClGnhlWJJ
|
||||||
|
MNMMNTmBLDmTLDSQmFDvvzwPWzsvDZFFcD
|
||||||
|
fmflRfGcCtGDDbRCRlhCmmBJQsvBBWWvtWBnBJvLLvLn
|
||||||
|
GFjdMMFGzVQvWWVWJQVJ
|
||||||
|
wjTZzjrFTHgZjTFjMwGRcfRcqlbhcccrcmmlqC
|
||||||
|
PvnvjHPnjRPPqvvnPqZNNWHTSdVDHwTLSDWDlTTTLl
|
||||||
|
MJswhgppwspJpJsGbhchbcMlLLDQdVSgVldt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|
rqLzTmqqMmmwrqwrJJwPTplhbRDphhdhDvnnhnRDnP
|
||||||
|
ggfctFfSRNgZFBRVfFfWfZNSvjjvjCChpDhhDCCjdvlDDD
|
||||||
|
NQfFRFgtffcGfcgZcfBqJrGLJJqLTwwmmHJrqz
|
||||||
|
WVGJCltslWJsbbtNJbDJPMrPLBNLrpNjfqQQMMNr
|
||||||
|
nTFnTmdRnTmmmdHZZnPQpLMfMZPMPqLZDqLf
|
||||||
|
HRvRFRTvvvRmnvFcFRndcwVVJWWGbsJGwgttlCzJlGDg
|
||||||
|
rfwdfLwLwwNdwbLcgCCTtFPvFPzWtWVtzvJF
|
||||||
|
MpjqDDQQRmQjDspzTWWthVWRvRVRzn
|
||||||
|
ZTQQQqlQZsqlrlgwNlgLcSdf
|
||||||
|
QqBNgbNNJvcgnbBQQgJjQZSJWppPWsGpDpSGPpWTRDTp
|
||||||
|
rrldddlrChLFpWPSSPWvPGCR
|
||||||
|
fhFltdLhHwVfvgcZZqjzNNtQgt
|
||||||
|
BMCMQZSMvSZSQTQTWvMSvrrTccgGRNljBFglGRgBVgFGRRGc
|
||||||
|
ffmdmwdLbDJwFVNlGRRVVbRR
|
||||||
|
dwJnJLfJwLhnPQSSNMvMqhMP
|
||||||
|
RpQDDCHQwMRpwpNMCwpZhgZrPSqQdgrqPqPZqq
|
||||||
|
zbtzmzzGbVzJSTScZqrthddT
|
||||||
|
LVLJlLBnGnWNHMDRHnCCDh
|
||||||
|
wQDcLhScLLBStHhctwVwsBjNTrssTjgNsgGCgssj
|
||||||
|
fWblbRqMZWRffldFZpqWRbTCsPrsTNgnCQjgTrMGGgsr
|
||||||
|
FZRpqdlWWbZZJJJppWWdHQVmLLDmzwDcLSVcQJLw
|
||||||
|
DlllCDRlflQRsRnlCCBhzvLFVhJzJVzh
|
||||||
|
jHjNNqdHqwNgpgqNcpgZwjZhJJbvdbPVhBbbvVvBvLzbPF
|
||||||
|
cpcgSwWqgVnftSSTTf
|
||||||
|
QmLZvjwwmDWFLNLqbqfF
|
||||||
|
JJSBMBpdpgSBRBHJgdHBNVbsgqVlqfbVFVlqVFqb
|
||||||
|
pCttfdCRMDCjhPDhmQ
|
||||||
|
nDjnzdcDbDtGdcQTvssHssHbbfTq
|
||||||
|
lVgRgpWCrMRVgVglRLjJmQFHqHHHsqFvFfTQsHSfMQ
|
||||||
|
VrlpmWmgWppllLpPPWPWljPBntcnhdBNPhZBZhGdDd
|
||||||
|
fQsRRfBHvRRjjvSgTwCTphdlphqBpn
|
||||||
|
WJrDZbrNJZPWJcZmWLrrbPczpCnTddqdshqhDgTTwlwwTqhs
|
||||||
|
brcPbZPcWGWssGtVfVMjFF
|
||||||
|
GBZgqHhHGBZcLcGMjVJhrjrbStjbbb
|
||||||
|
wTTNFPQpvDQTQLQvntRSbRJjVnrSDtJV
|
||||||
|
TTwzQzPPTvmWLTTcdWfdGdZgfZHfZH
|
||||||
|
VswNdtMgdsvQDJgdVNgQrrLlhrSCLflqfLrDnzLL
|
||||||
|
RbjRbcZGTGpRbzrTqChtflhSnt
|
||||||
|
mBjPRWpGcmBZGZpmZjtRbQQVwJgsPsQMsvNJdsVFdN
|
||||||
|
TDmDTTThRDbbZtpTSnhRcFJMglldGdrJltgBMtMB
|
||||||
|
jNjsWLqqqvzWswNqdccrFNBFMBlMrdMr
|
||||||
|
LjjqwvsWCwjHwQHHTbDHbbRZmnRd
|
||||||
|
qtnncCFCqjwjcDwnFQSGGRSBGBSvFdvrhR
|
||||||
|
JPZzpgPJWNJBRhqSvQvBgB
|
||||||
|
mZmJmMPWzmWmPLbmqTTJPfDHnHjCjflHjflfDcfMwC
|
||||||
|
VfJrplTqzVVlVVlpfTMJfqDtWSLgbHgDjSHLgjHWjrjb
|
||||||
|
vhGsRdsNRPRvvRhjSZjJLPDjDJttbZ
|
||||||
|
GvGhQmhBnQNmnJGvhdFqBFVqcllqMBCMlVCc
|
||||||
|
cnmsmmDCBDmcmvVnsVBtQQWWrrltQlrBfRHB
|
||||||
|
hqphjLZFhMMjZQGQWGfftQWf
|
||||||
|
JhFqhbjSLjMpqzJFbSLdFSggDwgmgcDVsVzVfvNvDvsm
|
||||||
|
mRdspZZggmbJbpDcDJDqPhvvGvrnVqPqpzvVVV
|
||||||
|
dSjSjQtwfQlLwjQSPrrqVqvGPGPVPjnP
|
||||||
|
fMQtFQLHSfLtHFttHMflfwHWgFJsDbmJRDWdFBRJWmcbsJ
|
||||||
|
lMMftpGHMntGtMMGpJnSPQvwzvvHscsdQscQsscQss
|
||||||
|
hbfmWWLggVFjVVQdvbQvbcdzwbRR
|
||||||
|
qZWFWTgTZhrLhLmWGlGGrSnJSNfGtSll
|
||||||
|
QVGdmgVGLdllrGVgnZrdBvNvBSSjSvWtBHBqNNmv
|
||||||
|
ThRjRFwpfTNBBqSBSSvT
|
||||||
|
MFzbzfDjFFCCFJpRpFwbwJRnZndDgsZlgLrQLDgdlglZnD
|
||||||
|
PjbDQvQPjbjjvtrQcpHBWnLfqnqGcHngnLdf
|
||||||
|
VTwmMzMFnqHBwHBB
|
||||||
|
lMTTNCzCZmClVVQjstQpPlprlHSp
|
||||||
|
MtMqBtwFFsMRZMMZMjJGZR
|
||||||
|
PHbpbPqHmVVCRGGCGRjv
|
||||||
|
pdrrgdrqPbpzrHQbbqQPLHcQBsNtNnwzNhSFfhtfffFffwDs
|
||||||
|
cPjpPcRJJVtSGGtJtffN
|
||||||
|
CldrWrmDHnHnmWmTWsNzzfbbFNhtsbbNGGfb
|
||||||
|
LCDTldCmnLLVwPVgQt
|
||||||
|
NJpFrbpFZhlzhbzzqCtgMCgRbqCRMMtm
|
||||||
|
dWcnntHQWcjRHHCVMqCsRg
|
||||||
|
vLnQDvnGptrzLPwp
|
||||||
|
dwTwTHwvZHqTrTRTlWtfzt
|
||||||
|
GbFFbFBPnGQBQcQcLbPjFtCSrtgMMLrMfrrWgRgStr
|
||||||
|
PnBnQhsGPQbnJRqwdRDwvJNDwq
|
||||||
|
zzjWtnQRntzSBjZccmZmmC
|
||||||
|
bdJdbdfJdFCGflfGwBJsmhmSMgmgcsmM
|
||||||
|
qDbGDbvrFbbvGdvdffFdTTWQzrTWTLWLNnttLnCH
|
||||||
|
WMMssTqCbpGzGSlmzLbG
|
||||||
|
FVdwftRRVDZPcdZtZVRcjmvQSzzLrmlrclSGms
|
||||||
|
DVfPFZDZRfVFPFHRPFRCphhMpCTHTsNgqHNWgn
|
||||||
|
LzBGCRjHCnmnHzdzLLjHwGplflfrfPcgtflgLFLlcrcc
|
||||||
|
hqhDMSSqWZsDMVWTVWmTcglglflFVflFrpPtggcv
|
||||||
|
sshbJsTsqWMbqNWbhbzzjzGBQjCJQnzwmzBw
|
||||||
|
QnpfLpbLfGbvgjHzjgmNRqbz
|
||||||
|
SSMBMZDwMwFsqgSPPmHlHj
|
||||||
|
BhMFJhMBddDMFcTdMVddrQfvrnCqnCffpqnVCLtC
|
||||||
|
lhrTZNJZjCRjSCvRSlTSLlrvFnMHQhVDnqnmqqqmQqPDHmqF
|
||||||
|
wcpGdtwtwzcbpzggCFPMqtMQmQqmVqHP
|
||||||
|
bBfwgWbfwBdGpppGGGbcBsTRLlZTZsTRTsRNZClJsvZL
|
||||||
|
nJLgNcQDNMlQHMvCbv
|
||||||
|
zphFpmTszmwhGGFhhtppNfffVlvZvHCCVZzbfzvS
|
||||||
|
mTTsmTRGstsFhWwtWjPRdjnJdjJnLjcLNd
|
||||||
|
MfBDjllflHLTpDhhppDDbp
|
||||||
|
NZBBnGJNnNPWTcTTmVhZCh
|
||||||
|
PSzgSgwrnzrSzBGJSJrSLQqfMHQfqgRgfjHLljll
|
||||||
|
RgbNmBbqgWHWRNRqHtcMlMwJJjcDtVlD
|
||||||
|
SzpFLGPddSGnnSLQZLtJJcclDlVjDQwMhDcc
|
||||||
|
LtTZCTttRqqqvqTN
|
|
@ -1,8 +1,11 @@
|
||||||
use std::collections::HashSet;
|
use chunk_iter::ChunkIter;
|
||||||
use common::{Day, Part};
|
use common::{Day, Part};
|
||||||
use phf::phf_map;
|
use phf::phf_map;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use intersection::hash_set;
|
||||||
|
use itertools::{Itertools, kmerge};
|
||||||
|
|
||||||
static VALUES: phf::Map<char, usize> = phf_map!{
|
static VALUES: phf::Map<char, usize> = phf_map! {
|
||||||
'a' => 1,
|
'a' => 1,
|
||||||
'b' => 2,
|
'b' => 2,
|
||||||
'c' => 3,
|
'c' => 3,
|
||||||
|
@ -68,18 +71,35 @@ pub fn run_day_and_part(day: Day, part: Part, inp: &str) -> usize {
|
||||||
fn part01_parse(inp: &str) -> Vec<usize> {
|
fn part01_parse(inp: &str) -> Vec<usize> {
|
||||||
let inp = inp.split_whitespace();
|
let inp = inp.split_whitespace();
|
||||||
inp.map(|row: &str| row.split_at(row.len() / 2))
|
inp.map(|row: &str| row.split_at(row.len() / 2))
|
||||||
.map(|(left, right): (&str, &str)| (HashSet::from_iter(left.chars()),
|
.map(|(left, right): (&str, &str)| {
|
||||||
HashSet::from_iter(right.chars())))
|
(
|
||||||
.map(|(left, right): (HashSet<char>, HashSet<char>)| *left.intersection(&right).next().unwrap())
|
HashSet::from_iter(left.chars()),
|
||||||
|
HashSet::from_iter(right.chars()),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.map(|(left, right): (HashSet<char>, HashSet<char>)| {
|
||||||
|
*left.intersection(&right).next().unwrap()
|
||||||
|
})
|
||||||
.map(|i: char| VALUES[&i])
|
.map(|i: char| VALUES[&i])
|
||||||
.collect::<Vec<usize>>()
|
.collect::<Vec<usize>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part02_parse(inp: &str) -> Vec<usize> {
|
fn part02_parse(inp: &str) -> Vec<usize> {
|
||||||
vec![]
|
let inp = inp.split_whitespace();
|
||||||
|
ChunkIter::chunks::<3>(inp.map(|it| HashSet::from_iter(it.chars())))
|
||||||
|
.map(|it| match it {
|
||||||
|
[first, second, third] => dbg!((first, second, third)),
|
||||||
|
})
|
||||||
|
.map::<char, _>(
|
||||||
|
|(first, second, third): (HashSet<char>, HashSet<char>, HashSet<char>)| {
|
||||||
|
*hash_set::intersection(vec![first,second,third]).iter().next().unwrap()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.map(|it| dbg!(it))
|
||||||
|
.map(|i: char| VALUES[&i])
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -92,7 +112,17 @@ PmmdzqPrVvPwwTWBwg
|
||||||
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
||||||
ttgJtRGJQctTZtZT
|
ttgJtRGJQctTZtZT
|
||||||
CrZsJsPPZsGzwwsLwLmpwMDw"#;
|
CrZsJsPPZsGzwwsLwLmpwMDw"#;
|
||||||
let result = 2 + 2 ;
|
assert_eq!(part01_parse(input), vec![16, 38, 42, 22, 20, 19]);
|
||||||
assert_eq!(result, 4);
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn part_02_example_works() {
|
||||||
|
let input = r#"vJrwpWtwJgWrhcsFMMfFFhFp
|
||||||
|
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
|
||||||
|
PmmdzqPrVvPwwTWBwg
|
||||||
|
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
||||||
|
ttgJtRGJQctTZtZT
|
||||||
|
CrZsJsPPZsGzwwsLwLmpwMDw"#;
|
||||||
|
assert_eq!(part02_parse(input), vec![18, 52])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue