Skip to content

Commit

Permalink
Updates and cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishco committed Dec 13, 2024
1 parent 6217eec commit 5849744
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions src/bin/05.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,6 @@ pub fn part_one(input: &str) -> Option<u32> {
.sum();

Some(result as u32)

// let (s1, s2) = input.split_once("\n\n").unwrap();
// let mut orderings = HashMap::<usize, HashSet<usize>>::new();
// for l in s1.lines() {
// let (x, y) = l.split_once('|').unwrap();
// orderings.entry(y.parse().unwrap()).or_default().insert(x.parse().unwrap());
// }
// let pages = s2.lines().map(|l| {
// l.split(',').map(|w| w.parse::<usize>().unwrap()).collect::<Vec<_>>()
// });
//
// let (mut p1, mut p2) = (0, 0);
// for mut p in pages {
// if p.is_sorted_by(|a, b| orderings[b].contains(a)) {
// p1 += p[p.len() / 2];
// } else {
// p.sort_by(|a, b| orderings[b].contains(a).cmp(&true));
// p2 += p[p.len() / 2];
// }
// }
// // (p1, p2)
//
// return Some(p1 as u32);
}

pub fn part_two(input: &str) -> Option<u32> {
Expand Down Expand Up @@ -89,29 +66,6 @@ pub fn part_two(input: &str) -> Option<u32> {
.sum();

Some(result as u32)

// let (s1, s2) = input.split_once("\n\n").unwrap();
// let mut orderings = HashMap::<usize, HashSet<usize>>::new();
// for l in s1.lines() {
// let (x, y) = l.split_once('|').unwrap();
// orderings.entry(y.parse().unwrap()).or_default().insert(x.parse().unwrap());
// }
// let pages = s2.lines().map(|l| {
// l.split(',').map(|w| w.parse::<usize>().unwrap()).collect::<Vec<_>>()
// });
//
// let (mut p1, mut p2) = (0, 0);
// for mut p in pages {
// if p.is_sorted_by(|a, b| orderings[b].contains(a)) {
// p1 += p[p.len() / 2];
// } else {
// p.sort_by(|a, b| orderings[b].contains(a).cmp(&true));
// p2 += p[p.len() / 2];
// }
// }
// // (p1, p2)
//
// return Some(p2 as u32);
}

#[cfg(test)]
Expand All @@ -127,6 +81,6 @@ mod tests {
#[test]
fn test_part_two() {
let result = part_two(&advent_of_code::template::read_file("examples", DAY));
assert_eq!(result, None);
assert_eq!(result, Some(123));
}
}

0 comments on commit 5849744

Please sign in to comment.