Skip to content

Commit

Permalink
feat: aoc2022-13 part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
msyfls123 committed Feb 11, 2024
1 parent 1a49545 commit 8ed868a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions advent_of_code/src/aoc2022/13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,17 @@ fn main() {
}).sum();

println!("Part 1: {}", compare_results);

let packets: Vec<String> = data.iter().flatten().map(|v| v.to_owned()).collect();

let one = "[[2]]";
let two = "[[6]]";

let one_index = packets.iter().filter(|p| {
cmp_str(p, &one) == Ordering::Less
}).count() + 1;
let two_index = packets.iter().filter(|p| {
cmp_str(p, &two) == Ordering::Less
}).count() + 2;
println!("Part 2: {}", one_index * two_index);
}

0 comments on commit 8ed868a

Please sign in to comment.