Skip to content

Commit a81daf2

Browse files
committed
use hashmap
1 parent 618a2ef commit a81daf2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

2024/day5/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use itertools::Itertools;
2-
use std::collections::BTreeMap;
2+
use std::collections::HashMap;
33

44
fn part1(input: &str) -> usize {
55
let split = input.split_once("\n\n").unwrap();
66
let ordering = {
7-
let mut map = BTreeMap::<usize, Vec<usize>>::new();
7+
let mut map = HashMap::<usize, Vec<usize>>::new();
88
split.0.lines().for_each(|l| {
99
let s = l.split_once('|').unwrap();
1010
map.entry(s.1.parse::<usize>().unwrap())
@@ -29,7 +29,7 @@ fn part1(input: &str) -> usize {
2929
fn part2(input: &str) -> usize {
3030
let split = input.split_once("\n\n").unwrap();
3131
let ordering = {
32-
let mut map = BTreeMap::<usize, Vec<usize>>::new();
32+
let mut map = HashMap::<usize, Vec<usize>>::new();
3333
split.0.lines().for_each(|l| {
3434
let s = l.split_once('|').unwrap();
3535
map.entry(s.1.parse::<usize>().unwrap())

0 commit comments

Comments
 (0)