1
0
This commit is contained in:
Jack Bond-Preston 2022-12-23 19:12:52 +00:00
parent cede3289dc
commit 04490516f0
Signed by: jack
GPG Key ID: 010071F1482BA852
4 changed files with 387 additions and 0 deletions

8
day3/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "day3"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

300
day3/input.txt Normal file
View File

@ -0,0 +1,300 @@
FzQrhQpJtJMFzlpplrTWjTnTTrjVsVvvTnTs
mScqSqqgcfPCqGPZcfGNSvTNsVVNSjNvWSNsNz
fPcPGqgCcHgFzQpJJtHtJH
DZDqqlrjplDHrNCmnBcHBMCRcJzb
RQFLStFvdcBbzdJbJM
PThQtwftTPFvtTPhvtFtfFtpZZllwjRNlsqNqqZjwpGlrZ
pPwtqgwJZPJLgQqSFlqhFFlqMd
DBmCWBBDWTRGvcVRTCCnnfQlFSdlzfhfdMWQfjhhQz
drmBVVCRgprPtrZp
HznjQjvmzDMVrQnMLJMMlfWgPSlJGWWJPl
BdcqqhcdBRpFhhZBthhctdJSJJWfgGFlJCSFgbWPCDJS
NdRTZdNqBwqtthpRBTTRqdtZrsLQVzrrzjzDwDsnmrQrnsrr
HZFZCFzZWszqsRTBZTNMhmthVTmhDppmMQVPpm
wjvSbJddvrvlrvnJSJJvlJmhPlhVPVtGVpQDBVMpphQP
frbrfrcvvnvjfwbcJgrrCBRsCFsNzRgRCHCqssRH
dDFNqNqZqPLNqvqTTvCLSPdZssGHClJQJcRHJGHHcHBcsMsQ
lrjmWgWWrhjgrppQHHMQrsQRJGcBJc
lVlmnwjmdTTSvVFN
FWNFHvQPmLGwwwSHtswwln
RfMJcDdfdcfdddfZjdchrtZmSmCZVtqVnZmrnrtC
JMmJcfjjphcghpgjhRGzGzBBGPFGNBvPTpFL
cVPVwStmmcQPBQPpSCppwhHZNNqHszNBhsNRNjqHzj
MfWdDgvdbnvgMTWgvgZfzmsZJHzNhqjqj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cmwMJwNm
TPjTDjfGWTLLljgzrWpZZbsqrFqhqbps
ppVLcfcwSLgpSLVLgWwtfshDNDqvWvGvlQZvDNHQHjqq
MPrzmdRrPPrCJFnMnMRRFRPdqqZQNQvjvZDGDlHhQvGNDG
BmBMBBJTMmPBJMMFCCFJRmrsTlVpVbpwLSVwLsgcwTVlVc
SSGzmFRzmRGLgSSmGMJFnvfvJnJVnJQnMl
cBpjHtjwNfcpNZtppHtCMlMPMlJBVlVQlvJPvJ
dNtNZwqWfqtqZWtHttsqHqrRrrdRTLbmmzSLmTGGmbrg
RrrddnrgnRbbgWdGrfnwgQwjDjDpvTpBQTwBPP
MHCStZJzSwvPjWQD
mcJWVHCCLcGLbdcn
PlMsdjPdGMjdPSrSjgddbLbmHHTszHZzpHmsTFvmpzZzmN
ntRJQVRfcQhcQWhnchBJWntTFTTTNTSpFtztmZFDTpDZ
hQfcfCBSwCccVJhSJnrPPGLqPlbPLCrqldgb
vgvWDMZvGpcqgqsP
tSdtjLHLQLHjdFdDddQSQhwlsGqwQlqqqhQsPhGc
tbRjtTLFRvTZDBrMrV

6
day3/sample_input.txt Normal file
View File

@ -0,0 +1,6 @@
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw

73
day3/src/main.rs Normal file
View File

@ -0,0 +1,73 @@
use std::collections::HashSet;
fn char_to_prio(c: char) -> u64 {
if c.is_ascii_uppercase() {
let ci = c as u8;
return u64::from(ci - b'A' + 27);
}
else if c.is_ascii_lowercase() {
let ci = c as u8;
return u64::from(ci - b'a' + 1);
}
0
}
fn main() {
const INPUT: &str = include_str!("../input.txt");
let input = INPUT.lines();
let mut priority_sum: u64 = 0;
for line in input {
let compartments = line.clone().split_at(line.len() / 2);
let items: HashSet<char> = HashSet::from_iter(compartments.0.chars());
let mut new_items: HashSet<char> = HashSet::new();
for c in compartments.1.chars() {
if new_items.insert(c) && items.contains(&c) {
priority_sum += char_to_prio(c);
}
}
}
println!("Priority sum: {}", priority_sum);
let mut input = INPUT.lines().peekable();
priority_sum = 0;
while input.peek().is_some() {
let lines = [input.next().unwrap().clone(), input.next().unwrap().clone(), input.next().unwrap().clone()];
for c in b'A'..=b'Z' {
let c = c as char;
let mut count: u8 = 0;
for line in lines {
if line.chars().any(|x| x == c) {
count += 1;
}
}
if count == 3 {
priority_sum += char_to_prio(c);
break;
}
count = 0;
let c = c.to_lowercase().next().unwrap();
for line in lines {
if line.chars().any(|x| x == c) {
count += 1;
}
}
if count == 3 {
priority_sum += char_to_prio(c);
break;
}
}
}
println!("Priority sum: {}", priority_sum);
}