From 7fe1a60dc2820a760ad3bd6eae948b0ef1e31622 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 3 Dec 2022 11:39:53 +0100 Subject: [PATCH] Solve Part 1 --- src/input.txt | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 53 ++++++++- 2 files changed, 351 insertions(+), 2 deletions(-) create mode 100644 src/input.txt diff --git a/src/input.txt b/src/input.txt new file mode 100644 index 0000000..37c2369 --- /dev/null +++ b/src/input.txt @@ -0,0 +1,300 @@ +BccTFfTPTsffdDDqsq +lGGLQwFhDgWdqvhW +wbLNjGjlwLFrpSbllrHnHHRmmJVBmZJRRVcBTc +vvGLllBBLtllJnJFMZNjFcNG +bdhrhTgmhRrpLJMMNJgNffnf +qhRmTpzpzVzmTTbmVhWWWpVvDtsLVlwBVHvSsDCvvBDl +sLlhhthVRndBZzwBdV +PfmsPsqsGFqrSQpqBDDwpddDDM +mFjvSFrjPSvLJWvbRssN +gWnWQtMMDQbQvMDjjcwsvqcwsSSqZq +HzPJTtmtZJJsqfBJ +hCFPrNNPVNzFtQhdQMWRhhDd +sNhmsQZdNdsztNpHGCdjcBcwCvGvCv +brSlRfFFppHwfTpf +MbRlRpqMnqRpMhVtsQQQVWsM +HsdttdfHrHrwdhftMHMSDnJFwlQSgQZQZggZSW +LjCTqBCmmmTqgFQQFQjlnnDJ +GCTLBCmTBDBDPTTzqLCBpVcctcHbtbrcMMsdsdtcPtdb +QnJLdNLfLRQjpLlPflfQnlnswRvwsHVWVHWVVDZwWHcrwV +zFbgtqCBhtgBhsDZVDNHwvDv +zgCGCFCFGtMpJjlGTnlnLN +ZFhJZbvZVmFpFnJbnZFbLnbHPrjjQdBdCrMPQMQHrrrrVC +gTzlqmNlTflmtTRHdDPqMjHDMrjdQd +wcRSwglcNSwgWmNzwNlJZLpphbbnFhvLWhnphb +lRRrcbRfQmwwBLSLlvjjSvvFtS +WbghzhHWbsdHhVtGLVSSvLFJtSGC +WWbWzPHDqPfBqRZrmqn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MccTpbLdHSfGfqwHZDHHqZqHZ +zbzvMpPLppLzLMjTBQRmssjBWRQjlmrN +VzzvggdvFdmffwmGpd +HNbnJTRTmCwwrRpR +LlTnWhLlhLJmLmtZtPcPcVFFPSZgZt +jHcZjHlHzLHHnSNSfL +pQWRrwPwrRWBWBPWBRrpdPmzhShsSFFNShLhnnvPtvSNNs +dzbmwVwbbBmGcqDbgllJCC +ndnvvzJDHvzHHHjnHjCCSDLgbSFwNFVbFVTL +mcQmQtpWTQGlmpTtMtqtpqTFsLcVSSscNCwLNLbwbbLNwV +pRZTQlhmtGWqqWnPHdnhjHrBjPPd +TtLpNHspTcLNNsLpthhsfmtjRSRlWWbzSwSRGwbWlWSSvlmS +qBJVnZZdJVZrZndbPbWwRzSMVGbbVS +QCdnBFBndBQDnrqrnqqNhpNNLpHthsThjGCTLL +phCgcdrFbPLpgrbFHqQqzzlbGWGqQbHW +SFTvTnVVMRnNTNfSHjHQMDlHwDWlQwDz +TZmTvsFNmvTtsggpdJLBBsCs +PBBWQjvsPsHVsNMcSzNDjcGggS +ZtrTfTrrrrdCqpdtLNnMLLqNcgMzgHLq +CZFmdTrJtbZrBvWHVVvHbPQW +djcrrBljMrTdCTcdCClClMlqRvtNqqSRwFbNbwvNBNpSzq +QhPmGJnPVGVHHNzSqpzFwztF +nhgPFmsnLPGLhPDJhGTcDjMfrMMjMZWfjfWj diff --git a/src/main.rs b/src/main.rs index e7a11a9..a7a0d4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,52 @@ -fn main() { - println!("Hello, world!"); +// https://adventofcode.com/2022/day/3 + +const DATA: &'static str = include_str!("input.txt"); + +fn item_priority(item: char) -> u8 +{ + if item.is_lowercase() { + ((item.to_ascii_lowercase() as u8) - ('a'.to_ascii_lowercase() as u8)) + 1 + } else { + ((item.to_ascii_uppercase() as u8) - ('A'.to_ascii_uppercase() as u8)) + 27 + } } + +fn part1() +{ + let mut priority_sum = 0; + for slice in DATA.split("\n") + { + if slice.is_empty() { continue; } + + let (left, right) = slice.split_at(slice.len() / 2); + + for c in left.chars().into_iter() + { + if right.contains(c) + { + priority_sum += item_priority(c) as u32; + break; + } + } + } + println!("The sum of the priorities of duplicate item types is {}", priority_sum); +} + +fn main() +{ + part1() +} + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_item_priority() { + assert_eq!(item_priority('a'), 1); + assert_eq!(item_priority('z'), 26); + assert_eq!(item_priority('A'), 27); + assert_eq!(item_priority('Z'), 52); + } +} \ No newline at end of file