Day 3
This commit is contained in:
parent
acd7d95238
commit
d032c76265
4 changed files with 407 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3,5 +3,5 @@
|
|||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "advent_of_code2022"
|
||||
name = "advent-of-code-2022"
|
||||
version = "0.1.0"
|
||||
|
|
300
res/03/input.txt
Normal file
300
res/03/input.txt
Normal file
|
@ -0,0 +1,300 @@
|
|||
zBBtHnnHtwwHplmlRlzPLCpp
|
||||
vvhJccJFGFcNsdNNJbhJsJQplQMRLQMlfdfTPCLfQQCT
|
||||
GPhjcjhZDjWtnSVH
|
||||
BNhHVhrGNVTbDHdDJdJRPJdSQQSJwPjR
|
||||
lvtsfbsqzwSnJcvjSm
|
||||
MftttFLftZMLgtgMbltMqZzbDNrTpVGhNWrDTrpTGNpZGZhD
|
||||
VSSHcTgTtTdtllZlzmmbljTn
|
||||
RqMqsFfQLLFLQFMMfRLPZLvPpCfWrbpmCbjCnfjlWmnrmmnm
|
||||
hqRDqPDRsqNHwtHSNBZtJd
|
||||
tNFDpDFrtdjfmjjjFmFFdScpZhZScTJgpHccHhMJgS
|
||||
lLzSlSCQqbsVhBghggBZgCcJ
|
||||
zRLVVLQnvQqVVzRldfWrwffjjdwSdfjv
|
||||
bpWqqqWvHBpwGBCCRl
|
||||
hJdjdJFQqdBBDMMC
|
||||
tFFzJZFtJSqtZJQsWLbNSTnffHfvTH
|
||||
lFhRZhFjPlqMlJqZJlJcRLwrLrwStRwtsVVtVSrgRV
|
||||
WcpDvDfBmpDHzWBDbpbmWmNVSSTzLTtrVswgttVVzwwr
|
||||
pbWfmGBpHfDmWnvvGbmWnjjMqPJMlMFPdGcjqPqPhP
|
||||
NjFNRlpVLFCSSlbBWWfw
|
||||
pssPZQQsMnzmtnQPttzDBbBJBcrrJWbrZSBJSbfC
|
||||
QTHPHspMNGHdhvRR
|
||||
QfPdSJfFJmthSthtwbsNLbPLlLTLpbvP
|
||||
nHnMBn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zSlv
|
||||
RzcbzdRFzbbzbzbFdZFTHMZPhVhVQMLrlrQPhLZlMM
|
||||
BNGfBvsNttVmMhlMLm
|
||||
BwGjpllswfjwpcFDWcWcbpdb
|
||||
SjzpswrLSDjVSpwlmZJBTBdNJLvBNvHQZT
|
||||
rCcCtbqgCfthggtbGGMqqghqZQvvQTBNJQHQZQTcZTJFZFFd
|
||||
CggGMtqMfWbbGghPhhbCMtmsSppSspjpmWzjVSWlVrrm
|
||||
PmWTPThTQWnLWQFl
|
||||
VNcSVfMbtsddBQNnNpdl
|
||||
sSjctwjVSzzccjgnTnDTHRDhqjRR
|
||||
WfMWfCNCjWWHNTccMjRjfRcMbqSwfVwqwsfGGbssrJSrswVw
|
||||
llLFQLlvlPFnhQBPBZQBqvBwzSzGGhShJVwShmsJbbmzSG
|
||||
lnPqvQZBFFBnnpgplFvtvHDjTdcTjTMMjCRNCMWgRC
|
||||
rprFNFFNjNLmMdgcqL
|
||||
BvzCQQbBQgffsDbvVHMdbcVqmLVqlmqq
|
||||
JvJCzBDJwnsRnQDszCBnnnQBrjZPjFpgZFTFZRpTrpZFGFtT
|
||||
wBHQQZHVCcpwDgdZdMsZjvMZFn
|
||||
GPSzlNlJLfzzzvsWdWLMmFWLMM
|
||||
NfqGSfrTNzRTqJfRbptQHFQFrwrFHBHw
|
||||
sNjVMVNVMzPzQgghcMsNzJtjSJtTFDTJtJnnDLjDnL
|
||||
CHwrdCpvCrwrWdpZqcpFttJSFJTLLHLJfbnbfD
|
||||
qrlZCwlqZrqqpWdlRqCRqdqcVNsVMzQzmNgNPBsRhVQVVzMs
|
104
src/d03.rs
Normal file
104
src/d03.rs
Normal file
|
@ -0,0 +1,104 @@
|
|||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
|
||||
pub fn d03() {
|
||||
let path = "res/03/input.txt";
|
||||
|
||||
let contents = fs::read_to_string(path).expect("Should have been able to read the file");
|
||||
|
||||
let cont_arr = contents.split("\n");
|
||||
|
||||
// build alphabet as hashmap
|
||||
let mut alphabet = HashMap::<char, i32>::new();
|
||||
let alphabet_chars: Vec<char> = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
.chars()
|
||||
.collect();
|
||||
|
||||
alphabet_chars.iter().enumerate().for_each(|(i, a)| {
|
||||
alphabet.insert(*a, (i + 1) as i32);
|
||||
});
|
||||
|
||||
// parse rucksacks into 2d i32 vec
|
||||
let rucksacks: Vec<Vec<i32>> = cont_arr
|
||||
.into_iter()
|
||||
.filter(|line| *line != "") // filter out empty lines
|
||||
.map(|line| {
|
||||
line.chars()
|
||||
.into_iter()
|
||||
.map(|c| *(alphabet.get(&c).unwrap()))
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
|
||||
// 1st task
|
||||
// calculate results - split each rucksack in half and find & sum up duplicates between halves
|
||||
let results: Vec<i32> = rucksacks
|
||||
.iter()
|
||||
.map(|r| {
|
||||
let (r1, r2) = r.split_at(r.len() / 2);
|
||||
return first_duplicate_value(&r1.to_vec(), &r2.to_vec());
|
||||
})
|
||||
.collect();
|
||||
|
||||
let result: i32 = results.iter().sum();
|
||||
|
||||
println!("Result 1: {}", result);
|
||||
|
||||
|
||||
// 2nd task
|
||||
// calculate results - find duplicates in each 3-rucksack groups and sum up
|
||||
let mut result = 0;
|
||||
for i in 0..rucksacks.len()/3 {
|
||||
result += first_triplicate_value(
|
||||
&rucksacks[i*3],
|
||||
&rucksacks[i*3 + 1],
|
||||
&rucksacks[i*3 + 2]
|
||||
);
|
||||
}
|
||||
|
||||
println!("Result 2: {}", result);
|
||||
}
|
||||
|
||||
// returns first duplicate value of 2 vecs or 0
|
||||
fn first_duplicate_value(vec1: &Vec<i32>, vec2: &Vec<i32>) -> i32 {
|
||||
let mut vec_set = HashSet::<i32>::new();
|
||||
let mut res = 0;
|
||||
|
||||
vec1.iter().for_each(|i| {
|
||||
vec_set.insert(*i);
|
||||
});
|
||||
|
||||
vec2.iter().for_each(|i| {
|
||||
if vec_set.contains(i) {
|
||||
res = *i;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
// returns first duplicate value of 3 vecs or 0
|
||||
fn first_triplicate_value(vec1: &Vec<i32>, vec2: &Vec<i32>, vec3: &Vec<i32>) -> i32 {
|
||||
let mut vec_set1 = HashSet::<i32>::new();
|
||||
let mut vec_set2 = HashSet::<i32>::new();
|
||||
let mut res = 0;
|
||||
|
||||
vec1.iter().for_each(|i| {
|
||||
vec_set1.insert(*i);
|
||||
});
|
||||
|
||||
vec2.iter().for_each(|i| {
|
||||
vec_set2.insert(*i);
|
||||
});
|
||||
|
||||
vec3.iter().for_each(|i| {
|
||||
if vec_set1.contains(i) && vec_set2.contains(i) {
|
||||
res = *i;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
res
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
mod d02;
|
||||
mod d03;
|
||||
|
||||
fn main() {
|
||||
d02::d02();
|
||||
d03::d03();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue