Rust Day 3
This commit is contained in:
parent
8ad6df2ab6
commit
29186c44c0
6 changed files with 385 additions and 3 deletions
2
rust/Cargo.lock
generated
2
rust/Cargo.lock
generated
|
@ -4,4 +4,4 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "advent-of-code"
|
name = "advent-of-code"
|
||||||
version = "22.2.2"
|
version = "22.3.2"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "advent-of-code"
|
name = "advent-of-code"
|
||||||
version = "22.2.2"
|
version = "22.3.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
@ -33,4 +33,8 @@ path = "src/day01/main.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "day02"
|
name = "day02"
|
||||||
path = "src/day02/main.rs"
|
path = "src/day02/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "day03"
|
||||||
|
path = "src/day03/main.rs"
|
300
rust/src/day03/input.txt
Normal file
300
rust/src/day03/input.txt
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
NJvhJcQWTJWTNTFFMTqqGqfTmB
|
||||||
|
VwVzPldRZVLVRmfsvfjvqfmm
|
||||||
|
ZDPDHZHVcvDhbvnv
|
||||||
|
FHHwHBzzVCWWmmCzCPrVmgBwbLTtRFFbbbttRGRLjTcLpbbT
|
||||||
|
vhZZvdsNSdSMdNvjncppCLcLnGnj
|
||||||
|
CDZZsNZMZqdNSdlNZCqrzPHDzgrgzwVVWwmwwm
|
||||||
|
ndlndntsFJntFvccLjjLrjBShcBBfc
|
||||||
|
GpCGHzVwmmzqQWSSSfWHBhQL
|
||||||
|
mpCMGGCZVzVwGGVwmJsZnFtZnTSTJtdsvl
|
||||||
|
nCnPDGmDNmVCsVQDmGSWqvzchWSjjcWGqS
|
||||||
|
gTnBRLpfTRnrTdZgdLfRdrThvqcvWWhFFWvcFSSgjqqzjv
|
||||||
|
pfZfTMwrbLTTfsbmQtlVtHHnbs
|
||||||
|
wNdSdsbTvTZMTvTv
|
||||||
|
rrdRWdWQhFVdHWBGWQmmmnnMvCfmnhvmCmtZ
|
||||||
|
rJrVDRWpGddpbSlNSlspPP
|
||||||
|
chTNrthMMwWMTjfsmRzZszJpwm
|
||||||
|
BLnFFCngbcBnbbldDlpRjGpmsCzGsGsRGmmG
|
||||||
|
dqvnvlgbqtcPPMhH
|
||||||
|
QcLNqZbCzJDQBJJRpwzRpdnRldgnpf
|
||||||
|
GmmmvVGsHrWffrlwdCWd
|
||||||
|
CMsFVVFjCmFStGQbbLZNBbJBcTjc
|
||||||
|
LQVggbQvcLbQLHgvVLhWGGsChssrMWfzGccc
|
||||||
|
qDnRTTRqJttPfWMChJhGslWlzh
|
||||||
|
qRTRwPBTBtRZdnjnqqqnQVbjbNLFbbfLgVmgHLQm
|
||||||
|
cZbzwCwZPlJcMLrNSNfHWNBBNZ
|
||||||
|
vsQsDCqtsDhmtjVrBNWNjBHrhr
|
||||||
|
TtDTGnvTlgbbRCGg
|
||||||
|
BgBlplHlsgNNsJlVpBtPwJhMPRRQSSttRtSP
|
||||||
|
bvhTnmdFTzddStwStQRddt
|
||||||
|
ZnZDLvnvqZzbbhFzzmTbnFsVjVlNgsCCNVsVLpNWVgsB
|
||||||
|
TdptqrrcVGhhzFtw
|
||||||
|
DRnSfwJlDmmDDVGv
|
||||||
|
RCSQNSCQZndwbcMqQrBB
|
||||||
|
wvRlrlwVwwqzgbZRdCJBWfmdzCWfBdhf
|
||||||
|
cFcsQpNtLLsGTtNGpMdPmDdPBmmBvJPWvDtC
|
||||||
|
TpjssTFFvLLLcFFQpwbwwHngjHRrZRqZVH
|
||||||
|
mqqddrPPcPmqPDlrQnjTrbvMvbHzzsjjpTvz
|
||||||
|
gtBWgGgVhLGWHzMDztzstDHj
|
||||||
|
hfWRhBBNBGgLNQDPwdNPcPdw
|
||||||
|
LhQzdhhbTzpMhddhhhTzhnZcBFllHZFtrrHZHMHFjlHr
|
||||||
|
mwwssqDvjptrvplr
|
||||||
|
NCSgVDPDwmDgVJVpLfTznQJdhfLhnhQQ
|
||||||
|
GzjzDhjhhZzcrRgQCBjBPBBjQCgT
|
||||||
|
vHHHmntsbSgLwbsSmNHbwNbvpqPCBVppCpFTpTPTBtqWBCqV
|
||||||
|
NJbwNSwdndvmvwhGhgzcfMcDJfgJ
|
||||||
|
GncgDvvcMGnttjDvrgRRFSZZLZFWdJFJwGQwZBWZ
|
||||||
|
bPqpChPfsshfZZBdZdLTFZ
|
||||||
|
lNqqsClmbsNlPbHqPsmblmsrHdvdMngcVrjggvrvggRDcn
|
||||||
|
bDvtgVVVpMQvjQWmQL
|
||||||
|
rwTflmlfZJBBdQWQWjQqdM
|
||||||
|
HsJJmZZwscHrwTrcRbzpcbPgtCSbgz
|
||||||
|
CsCsRvshMjpbqCqf
|
||||||
|
ncblgDBgtDmmmTlBgwlgbHHqMFHLqPDMHPHHpqWfFM
|
||||||
|
TcBctSmTZTtSTzsZvsvJZRsGVb
|
||||||
|
znznvngttwltzlLwhtThHbqHPvNbNHSSHmmNWHjP
|
||||||
|
FBcLrRMFQpPqpPSpqHHW
|
||||||
|
fRQMJZJfrcMcMVrQJJftnwCzVCltgTnstTVnVL
|
||||||
|
MfLlRfCMrLzRlQgwNqQFcsGd
|
||||||
|
jtTjjBTvbdqcGjqFcj
|
||||||
|
vvShDSBDppzhCmzq
|
||||||
|
plWMptTvfrnncvcRfwqzqLGhzhzThNzNNJqD
|
||||||
|
jSdSHFPQQbdPCQCssjSbBmhJGNZZNGNqqJNBlJqqLh
|
||||||
|
VCCCVCQgjdddjCgljCjbbwgRRttgrpftfWrgvpwpnf
|
||||||
|
MWlbBcPjjvvjPWWMPqgRQZfJZDGGbRZJffQQwh
|
||||||
|
HrHrnncHpzrJQJfVDQVR
|
||||||
|
zzsSTtSTLzsspSdtTmHHmpmtFgqcgPlgFqWBqqqBMdWWvFlg
|
||||||
|
nSqBbJbqlnBBClVZcMgZVgcP
|
||||||
|
FQwrwHrRwWWFBRPNgNgcCGZZZC
|
||||||
|
rWFWFTwpwwWzHrnDbfJDLDbBBbbz
|
||||||
|
BMmNtLMMtFCNFNMvvLmcndpgcdgppPrgrGPPrgJD
|
||||||
|
WVWWhbTtVnGpjrrPhr
|
||||||
|
HWssSTHWfRHRsQQFLvfvFFCLCNMNlt
|
||||||
|
sTmDsQffVrrLCjTFltTFWL
|
||||||
|
BnwwQBJbJndMMRzMwCLlWlLWWCWLLtRlWF
|
||||||
|
cqqBMcMqwnznMGzcvDmQhrvssHmPDVssrP
|
||||||
|
pQGQGJDDrDVJbbfVzvvgPcCZwhZhncscZWWc
|
||||||
|
SqMMlBBljMmRlchhPTqThCZnPs
|
||||||
|
FMjMBmjRNFHQJJpHVhVDhG
|
||||||
|
tHNNdBdNtBBBMgsMpsZm
|
||||||
|
wVPzVvbwqzhrVqvjqzzsZpDsZDsZmsCPCgZgCM
|
||||||
|
bVbvLThvvbrWqHmmnJLdHdJQLn
|
||||||
|
PzTspPZpdLLDZTplPLpPDpvbfhnqNvqzfvNMzQQfNwnQ
|
||||||
|
GWRHmjmFWMMSnhbhHw
|
||||||
|
JWWcmtBrBtWBFWGJpsgTgldhLVLpJl
|
||||||
|
DwLMDzLMhvMcwvgdVqWWlCVgvlqF
|
||||||
|
TTSBBRpbStHZVgjWFldjRVlV
|
||||||
|
SnbTBdJBmnpQzMPDMcMznr
|
||||||
|
nNlMNBPPNtJQnbZhZsgSbh
|
||||||
|
czzCjcwTdvSbgQNcgNQq
|
||||||
|
VTdNdGDTzDTdlFFPtBrtLtDr
|
||||||
|
FMbbfMlzvFsmgVZmmg
|
||||||
|
SrNTHGmdSQDqLhtQhhgggs
|
||||||
|
dRDTSDPPcHRdHGDHlwJBbmwljmMcfjbW
|
||||||
|
sQgWLtqLtWhdqlpNZRpG
|
||||||
|
blTHTjlvTCJnJvRZdGGhHHGZhFGV
|
||||||
|
CCDlJcln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FDs
|
||||||
|
LZQNQbMrZppLNLQplvlGLNvVmmmfjbwVCfjbwJwCmBCwfj
|
||||||
|
ShTPRFtTHZPCsnwswsFwCF
|
||||||
|
WtHRPdThSqZTRtDqtdRWTdpGDLLzrNczvzMGLlQLGDDM
|
||||||
|
hdcffBvldjhCMljqPwWwWNwWdwqHZr
|
||||||
|
LtQmbQRVsZQZMZPQSN
|
||||||
|
tmMRsJMpDhjJzJhv
|
||||||
|
wNQCMFCDQDBmrHmmRWrrHN
|
||||||
|
SShLnfqpcqpSZSfrzJvRVrvfrrJH
|
||||||
|
cRpqdGclpScltTQQtsFQMQsTCT
|
||||||
|
NCjggZmgfBgnBmgWbcwcTFctcWWfvb
|
||||||
|
HsDGthRGrtppSQpbFFJTVcJdFbTRvd
|
||||||
|
rPDGhDDrSzZLtzBLZMCB
|
||||||
|
RsBBMBsCBlFFCgRsBJzlMjMPNSdPhSrSrzLbmSDrDNmDSd
|
||||||
|
pZHZZJpGHHHpTTHvTncZqVLdqLbhLrDLdhrSLLbLDDdD
|
||||||
|
tGtwnJccvCtCffMBgt
|
||||||
|
wbddvVjfwPhbjjbDbbvbjvTNCNmfHZfpCZRJNzCmJmnJNC
|
||||||
|
BslcLtclZWsZJWNrRRNRpRmR
|
||||||
|
BSLBlScGtFMcssMBBFGLlQZTDZQjPddVwwbTdvvdhTZb
|
||||||
|
NSZHzmLZBnzHmLLzLSntDttDDtddhDtttDWW
|
||||||
|
QgfjsrrvNNJwtMddcvcvtq
|
||||||
|
jrfgfQpQrTTVLSNBClFV
|
||||||
|
GQWcWWPPQRcrJQNDdRcDmmLCFSnqNSmqhCNvFnql
|
||||||
|
zHfwjzpMjwZmCLqvvnlljC
|
||||||
|
ZgtVZBtHHZtgQGgPrbPRJdPv
|
||||||
|
TWdWpJTJTdgLWfWLlLFLrfrgBGsNqhGslBGHqSNqqBNshnws
|
||||||
|
ZpQmjzbZZCjZCCCPZtttRCCwsBnHNssBHbShsshHqsGBqN
|
||||||
|
RDRRPpPCzmZCtRpVVJFrfTfWFLLJggJrDv
|
||||||
|
pDDFlglsvFMgntlTMMqNffmTdfddRM
|
||||||
|
jhGJLVCHQpHGQCCzLjWdTTdZZdNdcRWNccWfNN
|
||||||
|
jQjSGjrjCQLhzVSLSCSHGDpngbrnDFtFBwBglBnBvg
|
||||||
|
wsLzstsgszcpcGLHGpcgcghlDBvQvjQvbFbQCbJBtCCJJv
|
||||||
|
mnSqRSSqSRThWRnmWWRSJDFTFCFCblbBCFQFCjFj
|
||||||
|
rZRRWqSSdZZfMVnZLspPsMgHpzMhHGPg
|
||||||
|
mwHrCLSWWwrsHCHDDsVrsmhfFZFnSSBlFlgZbbgBglbggj
|
||||||
|
GJdpcRtGJvNRdcPtdpJJdbQZfjfQBlnQBjnBtbfFnB
|
||||||
|
qcPpqqzFzJqvPVCCmWrVwhrWrz
|
||||||
|
jjMbvbhDvnRjNRGMmjbMZftSSwwwthJSffStctcwqd
|
||||||
|
lTQrVlpCVvCcfdcSJqLVcw
|
||||||
|
srHFWCHrFlrHlrsBsprljjRmDZZnmbDngNBgbNZv
|
||||||
|
MgTlQJlTQJZWpgLrRssrVqqqpRts
|
||||||
|
bBNbbzSSjMBPjzhMjsPtRVVRVPRqLttGGs
|
||||||
|
SjHBbfjNCDfjZgTlZdMJnDJW
|
||||||
|
lpThgTwtplhghgwhThqnnrdZctSZSjSZcRSRfbdrrc
|
||||||
|
RBVBGvmBmfdrcvrbbr
|
||||||
|
PmVGNGmmGRLLQwwLqTnglQ
|
||||||
|
nHwnBwBTnFHQwRsMhwghmzcm
|
||||||
|
GtprdCpdtqWdbqbrfdnPPszsWmRzRnShPszS
|
||||||
|
dGptbCfCrlnVDBJNLDLLVDLQ
|
||||||
|
CZtCjhTndCzqbCNq
|
||||||
|
dwpGvpsmwGslDszrNNrzqDMzWMgJ
|
||||||
|
vmcGccvpBVPTVTjTdTTTdZ
|
||||||
|
jWZhvZLjZfCZDwrDrSSzJGhVdJccscGsgV
|
||||||
|
blMBlRqqqgSJLBLcsJ
|
||||||
|
blmHLmFMMMnRqLmMMFqHmfPDfjQDnCDDQrZvfCjvDr
|
||||||
|
rnvnHrDLFZmMFLvrHQBMGQggBztzglplRl
|
||||||
|
sbWWhdNzsshsfhcsjJJPPbWdtQGVGllRTRjRRgBgQlpRlppB
|
||||||
|
PPCCwNWhPhNfWCzbqmFnDFFnCDLSrvZS
|
||||||
|
GChNjwWlWJWTJZBggvdgnQgdhdnd
|
||||||
|
HPsHfHHrpHDpFFrcSfsfpCMmQdntLBMgtmtBgDdLLC
|
||||||
|
SqpPscpPzpSWzjlCjjCGjl
|
||||||
|
nvgLvcLgvgvngbLprpJNTDCCRNVJrNPlDDTV
|
||||||
|
WZsMtsffGQtMzWFqFmWmWsVNJNlDwwCDVRTwJlCCDVLz
|
||||||
|
BQfGZGmmsMWFstWFmfMsfBccdncbpbSbvbbvHnLbpc
|
||||||
|
tsmDsvswNZmcZTccfh
|
||||||
|
zCTpGCbWBRWFWHGRFZJbMbJfnrhnhfMnnZ
|
||||||
|
TzFGFBRLdpHHNNQddDQDvwQN
|
||||||
|
fhBBpJgdHddjZQfmVmNzNNLmFN
|
||||||
|
qvMRrvlbwqlbTTMBMvLssFNmVzzwFDmLLzVD
|
||||||
|
TRSRWqRRMcBHhGHcdGgPGp
|
||||||
|
lSjHmtmnpHStblnpSlHSrtmMzLWzqzqCZDDTzTTWqMFqCqVV
|
||||||
|
sLRLLfPPRQfCTqqVVqFT
|
||||||
|
dNJgRPNQNsJJhBRvdJvQvNNsjSrrSmrcctpbpHtBrBjLjmSH
|
||||||
|
nwFwpppjfwSlpLTsqsTgNshhjM
|
||||||
|
ccBRGvtsmgGNPqNNGP
|
||||||
|
BCcJHvssdcWBCVmVHSSrZrwVzblpwbzZnf
|
||||||
|
rcfQRrBPPczjcRBctZDNlnVNHbgZGjVDjN
|
||||||
|
TvMsFJGSFMhJnNZlwVVnDNTZ
|
||||||
|
qhSqqmqLCLhFdJLqSvLhmQRQRWcRPczPtz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||||
|
zvttlFpgdtldwwvftPDPTWQdBZrsrWrGBZ
|
||||||
|
hFlFmhRFvfCbmWJWHcnj
|
19
rust/src/day03/main.rs
Normal file
19
rust/src/day03/main.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const INPUT: &str = include_str!("input.txt");
|
||||||
|
|
||||||
|
mod part_1;
|
||||||
|
use part_1::part_1;
|
||||||
|
mod part_2;
|
||||||
|
use part_2::part_2;
|
||||||
|
|
||||||
|
pub(crate) fn character_priority(character: u8) -> u64 {
|
||||||
|
(match character {
|
||||||
|
b'a'..=b'z' => character - b'a' + 1,
|
||||||
|
b'A'..=b'Z' => character - b'A' + 27,
|
||||||
|
_ => panic!("Invalid character '{character}', no priority"),
|
||||||
|
}) as u64
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
part_1(INPUT);
|
||||||
|
part_2(INPUT);
|
||||||
|
}
|
36
rust/src/day03/part_1.rs
Normal file
36
rust/src/day03/part_1.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
pub(crate) fn part_1(input: &'static str) {
|
||||||
|
let rucksacks = input.lines();
|
||||||
|
let compartments = rucksacks.map(|rucksack| {
|
||||||
|
let compartment_size = rucksack.len() / 2;
|
||||||
|
let compartments = (
|
||||||
|
rucksack
|
||||||
|
.bytes()
|
||||||
|
.take(compartment_size)
|
||||||
|
.collect::<HashSet<_>>(),
|
||||||
|
rucksack
|
||||||
|
.bytes()
|
||||||
|
.skip(compartment_size)
|
||||||
|
.take(compartment_size)
|
||||||
|
.collect::<HashSet<_>>(),
|
||||||
|
);
|
||||||
|
compartments
|
||||||
|
});
|
||||||
|
let mut running_sum = 0;
|
||||||
|
for compartments in compartments {
|
||||||
|
let same_bytes =
|
||||||
|
HashSet::intersection(&compartments.0, &compartments.1).collect::<Vec<_>>();
|
||||||
|
assert_eq!(
|
||||||
|
same_bytes.len(),
|
||||||
|
1,
|
||||||
|
"{}",
|
||||||
|
same_bytes
|
||||||
|
.iter()
|
||||||
|
.map(|byte| char::from(**byte))
|
||||||
|
.collect::<String>()
|
||||||
|
);
|
||||||
|
running_sum += crate::character_priority(*same_bytes[0]);
|
||||||
|
}
|
||||||
|
println!("Part 1: {running_sum}");
|
||||||
|
}
|
23
rust/src/day03/part_2.rs
Normal file
23
rust/src/day03/part_2.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
use crate::character_priority;
|
||||||
|
|
||||||
|
pub(crate) fn part_2(input: &'static str) {
|
||||||
|
let rucksacks = input.lines();
|
||||||
|
let compartments = rucksacks
|
||||||
|
.map(|rucksack| rucksack.bytes().collect::<HashSet<_>>())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
assert_eq!(compartments.len() % 3, 0);
|
||||||
|
|
||||||
|
let mut running_sum = 0;
|
||||||
|
for group_compartments in compartments.chunks_exact(3) {
|
||||||
|
let group_bytes = &group_compartments[0]
|
||||||
|
.intersection(&group_compartments[1])
|
||||||
|
.copied()
|
||||||
|
.filter(|byte| group_compartments[2].contains(byte))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
assert_eq!(group_bytes.len(), 1);
|
||||||
|
running_sum += character_priority(group_bytes[0]);
|
||||||
|
}
|
||||||
|
println!("Part 2: {running_sum}");
|
||||||
|
}
|
Loading…
Reference in a new issue