Skip to content

Commit 2f8cf3b

Browse files
t:wq
1 parent 4bea488 commit 2f8cf3b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

2024/src/day01/bin/day01.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod part1;
66
mod part2;
77

88
fn main() {
9-
let _input = read_to_string("../input.txt").unwrap();
9+
let _input = read_to_string("./day01/input.txt").unwrap();
1010

1111
// start timer
1212
let start = Instant::now();

2024/src/day01/bin/part1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ pub fn part1(_input: &str) -> usize {
44
let mut v1 = vec![];
55
let mut v2 = vec![];
66

7-
for line in _input.lines() {
7+
_input.lines().for_each(|line| {
88
let mut a = line.split_whitespace();
99
v1.push(a.next().unwrap().parse::<i32>().unwrap());
1010
v2.push(a.next().unwrap().parse::<i32>().unwrap());
11-
}
11+
});
1212
v1.sort();
1313
v2.sort();
1414

15-
let result: i32 = std::iter::zip(v1, v2).map(|(l, r)| (l - r).abs()).sum();
15+
let result: i32 = v1.iter().zip(v2).map(|(l, r)| (l - r).abs()).sum();
1616

1717
return result as usize;
1818
}

0 commit comments

Comments
 (0)