Skip to content

Commit 9b8ee4b

Browse files
committed
use unzip for parsing
1 parent 561401e commit 9b8ee4b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/bin/01.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ use advent_of_code::maneatingape::hash::*;
44
use advent_of_code::maneatingape::parse::*;
55

66
fn parse_data(input: &str) -> (Vec<u32>, Vec<u32>) {
7-
let first = input
7+
input
88
.lines()
9-
.map(|line| line.iter_unsigned().next().unwrap())
10-
.collect();
11-
let second = input
12-
.lines()
13-
.map(|line| line.iter_unsigned().nth(1).unwrap())
14-
.collect();
15-
16-
(first, second)
9+
.map(|line| {
10+
let mut iter = line.iter_unsigned::<u32>();
11+
(iter.next().unwrap(), iter.next().unwrap())
12+
})
13+
.unzip()
1714
}
1815

1916
pub fn part_one(input: &str) -> Option<u32> {

0 commit comments

Comments
 (0)