Skip to content

Commit

Permalink
use hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
mirsella committed Dec 5, 2024
1 parent 618a2ef commit a81daf2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 2024/day5/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use itertools::Itertools;
use std::collections::BTreeMap;
use std::collections::HashMap;

fn part1(input: &str) -> usize {
let split = input.split_once("\n\n").unwrap();
let ordering = {
let mut map = BTreeMap::<usize, Vec<usize>>::new();
let mut map = HashMap::<usize, Vec<usize>>::new();
split.0.lines().for_each(|l| {
let s = l.split_once('|').unwrap();
map.entry(s.1.parse::<usize>().unwrap())
Expand All @@ -29,7 +29,7 @@ fn part1(input: &str) -> usize {
fn part2(input: &str) -> usize {
let split = input.split_once("\n\n").unwrap();
let ordering = {
let mut map = BTreeMap::<usize, Vec<usize>>::new();
let mut map = HashMap::<usize, Vec<usize>>::new();
split.0.lines().for_each(|l| {
let s = l.split_once('|').unwrap();
map.entry(s.1.parse::<usize>().unwrap())
Expand Down

0 comments on commit a81daf2

Please sign in to comment.