diff --git a/.aoc-cache/3.txt b/.aoc-cache/3.txt new file mode 100644 index 0000000..01be6a6 --- /dev/null +++ b/.aoc-cache/3.txt @@ -0,0 +1,300 @@ +FqdWDFppHWhmwwzdjvjTRTznjdMv +ZBJrDVfQcfSRMLjZnjjM +cBffPfbrbQcgQJggfVQJBPbCwlPtWFDWHFHhpmmGlGmlqmDG +PNbMLgmPgRDgRtMPDdmdbmdmQrTBVCZnVnpCnNHHVZBNVZHc +ljvvqhlvshhnrcpBZqpTcr +zGhWzFTJvsFttddWbMRdmP +hhGdDhfdDhmdnHwtzzRtdzbzQQQg +WTTZJLsvLRJCcWJWScWWLtzjwBzBttbBzSwVQjQBtt +vLJcLLTRsvsTZPqHGhFHGhhPhfqD +dJszLvzvCZZsJmszCrrdFmpppMpDMQPMgmDcDgSS +nRjRbnnjlNhblnjtVtQlWttMFPfMfPgDMpBgSBPgBS +GWVQTVTnTNhjblQNRsdJLLdTCdzdZLrdrJ +RnLJBfmJfmNBHlQvvbdQ +grhgrtqgjJhhggNHqvwWqvbNlbHw +GVTTsFFjJjVVFVGCFTJDDjhFcZmRMZfnZcncSpMSGcRPZpLp +bwSNRNSRzSWnPnJRldMBMQmMlsCcPPCP +FGpDqTTVFFprpjLVQMMGtMclcmHGtBdc +TjhhgTLpVZhpLDZqrTqZVpBSwJwzNnWNWJvzzNSggwwN +PHTMsmwrJMwLJvJddvdHwvcWnnWfccqGnhhfGcDqsnGc +tZVlzQZblBgcSqqRhRmzqf +CmlgmZlQtFtZNlVZdHLMrMvvCrrvvTTC +PrDGBBddprmzddrSqccRgSTpqbsMRR +hvLtfFNvvZNfGGfRgbqsRNlTSSgsbM +QQQjZHHQjvththFffCHPPzmGrmDzDWrWBw +GrjGrpjjCsnwhsGGPwlPTPLPVttPqLVl +HzSHHhczRlLTHqqq +DbhvFSSzQcZbcFbcQjrJrMJmmZnGJmJnjn +mvTDsJLwzlWNDDnZngZNdd +BVtPqFMqtvQFqPqjFBMVtRZGNGhfNcfQdp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RZVrVvFr +gPGgPJSTPJtHncnjWDhDMDhP +ZWWqBqqmgFFDMTTWDMwwcW +ddGPpJQPprRSCrQzJPJGjHDvssMTDZDwcHhMsHsMHS +zNRGrCRRCjPpdGQJNglqntnbtgNBZtFqtt +pslQSspQrqHfgMRl +tJBTjsTLGMBGMFMg +tDwnhZdnLdZDwczzcPvsVvVW +nZnMSDnGtnzmzWZZcMmgMcHwFFVHhHwbHsVrwQhVhF +dlTqNqfTjdJflCppCQQRHVwFRJrvJsFVQs +LNTqBLPprpLLzWtSnMZBMDGm +PBjlPvvcJlJzwqjnnjLnwm +dMfdpVfVhGVfVpVTtWWbzwngLMLwMRCmgmLMmsww +SWppdTrprThhrGVztcrllrQJZNlBZlrNZB +TTrNcjGNWDdDPDpPjDPNrbmFPfQSFmfSMCmCfSmSSR +sshhqshzBVnzHgwCMbCwcfmRFmRMbm +gHVVnBzJcBgVhtZZtgJhpGrGNpvDpddvprNGrlTJ diff --git a/Cargo.lock b/Cargo.lock index df53ee0..f89ed33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,12 +17,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + [[package]] name = "aoc-2022" version = "0.1.0" dependencies = [ "aoc_proc", "color-eyre", + "regex", "time", "ureq", ] @@ -272,6 +282,23 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + [[package]] name = "ring" version = "0.16.20" diff --git a/Cargo.toml b/Cargo.toml index 687b16f..26d689b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,4 @@ color-eyre = "0.6.2" aoc_proc = { path = "aoc_proc" } ureq = "2.5.0" time = "0.3.17" +regex = "1.7.0" diff --git a/src/bin/day_2.rs b/src/bin/day_2.rs index a645361..b25d671 100644 --- a/src/bin/day_2.rs +++ b/src/bin/day_2.rs @@ -1,4 +1,3 @@ - use std::str::FromStr; use aoc_2022::prelude::*; diff --git a/src/bin/day_3.rs b/src/bin/day_3.rs new file mode 100644 index 0000000..3ad2014 --- /dev/null +++ b/src/bin/day_3.rs @@ -0,0 +1,59 @@ + +use aoc_2022::prelude::*; +use regex::Regex; + +type Input = Vec<(String, String)>; + +fn parse(s: &str) -> Result { + let mut backpacks = vec![]; + for line in s.lines() { + let (part_1, part_2) = line.split_at(line.len() / 2); + backpacks.push((part_1.to_owned(), part_2.to_owned())); + } + Ok(backpacks) +} + +#[aoc(day = 3, parse = parse, test_cases = ["day_3.txt"])] +fn day_3(input: Input) -> Result<()> { + // Part 1 + let mut sum = 0; + for (c1, c2) in &input { + let regex = Regex::new(&format!("([{c1}])"))?; + let overlap = regex.captures(&c2).expect("there to be an overlap").get(1).expect("there to be an overlap").as_str(); + let overlap = overlap.chars().nth(0).unwrap(); + let offset = if overlap.is_ascii_uppercase() { + 26 + } else { + 0 + }; + sum += offset + (overlap.to_ascii_uppercase() as usize - 0x40); + } + + println!("Part one: {sum}"); + + sum = 0; + for group in input.chunks_exact(3) { + let mut present_in_all = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".to_owned(); + for (c1, c2) in group { + let elf = c1.to_owned() + c2; + let re = Regex::new(&format!("([{elf}])"))?; + let mut new_present = String::new(); + for m in re.find_iter(&present_in_all) { + new_present.push_str(m.as_str()); + } + present_in_all = new_present; + } + let badge = present_in_all.chars().nth(0).unwrap(); + let offset = if badge.is_ascii_uppercase() { + 26 + } else { + 0 + }; + sum += offset + (badge.to_ascii_uppercase() as usize - 0x40); + } + + // Part 2 + println!("Part two: {sum}"); + + Ok(()) +} diff --git a/test_cases/day_3.txt b/test_cases/day_3.txt new file mode 100644 index 0000000..9919ffa --- /dev/null +++ b/test_cases/day_3.txt @@ -0,0 +1,6 @@ +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw \ No newline at end of file