feat: day 3 (17:01.34)

This commit is contained in:
Ashhhleyyy 2022-12-03 12:07:13 +00:00
parent ca9aa96fb1
commit e2a7024ca4
Signed by: ash
GPG key ID: 83B789081A0878FB
6 changed files with 393 additions and 1 deletions

300
.aoc-cache/3.txt Normal file
View file

@ -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
DbhvFSSzQcZbcFbcQjrJrMJmmZn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sGSCLc
hjdjCfQCLdQcWMfDDQhLsLCjqvVqzzZZprBFbzVdvVnqnBbd
NTglmJGJRnRZVrVvFr
gPGgPJSTPJtHncnjWDhDMDhP
ZWWqBqqmgFFDMTTWDMwwcW
ddGPpJQPprRSCrQzJPJGjHDvssMTDZDwcHhMsHsMHS
zNRGrCRRCjPpdGQJNglqntnbtgNBZtFqtt
pslQSspQrqHfgMRl
tJBTjsTLGMBGMFMg
tDwnhZdnLdZDwczzcPvsVvVW
nZnMSDnGtnzmzWZZcMmgMcHwFFVHhHwbHsVrwQhVhF
dlTqNqfTjdJflCppCQQRHVwFRJrvJsFVQs
LNTqBLPprpLLzWtSnMZBMDGm
PBjlPvvcJlJzwqjnnjLnwm
dMfdpVfVhGVfVpVTtWWbzwngLMLwMRCmgmLMmsww
SWppdTrprThhrGVztcrllrQJZNlBZlrNZB
TTrNcjGNWDdDPDpPjDPNrbmFPfQSFmfSMCmCfSmSSR
sshhqshzBVnzHgwCMbCwcfmRFmRMbm
gHVVnBzJcBgVhtZZtgJhpGrGNpvDpddvprNGrlTJ

27
Cargo.lock generated
View file

@ -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"

View file

@ -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"

View file

@ -1,4 +1,3 @@
use std::str::FromStr;
use aoc_2022::prelude::*;

59
src/bin/day_3.rs Normal file
View file

@ -0,0 +1,59 @@
use aoc_2022::prelude::*;
use regex::Regex;
type Input = Vec<(String, String)>;
fn parse(s: &str) -> Result<Input> {
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(())
}

6
test_cases/day_3.txt Normal file
View file

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