diff options
Diffstat (limited to '2022/day1')
-rw-r--r-- | 2022/day1/part1/src/main.rs | 2 | ||||
-rw-r--r-- | 2022/day1/part2/src/main.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/2022/day1/part1/src/main.rs b/2022/day1/part1/src/main.rs index 637b4e3..a177d98 100644 --- a/2022/day1/part1/src/main.rs +++ b/2022/day1/part1/src/main.rs | |||
@@ -4,7 +4,7 @@ fn main() { | |||
4 | let input: String = include_str!("../../input").to_string(); | 4 | let input: String = include_str!("../../input").to_string(); |
5 | let mut calories: Vec<usize> = Vec::new(); | 5 | let mut calories: Vec<usize> = Vec::new(); |
6 | 6 | ||
7 | for (key, group) in &input.lines().group_by(|line| *line != "") { | 7 | for (key, group) in &input.lines().group_by(|line| line.is_empty()) { |
8 | if key { | 8 | if key { |
9 | calories.push(group.into_iter().map(|i| i.parse::<usize>().unwrap()).sum()); | 9 | calories.push(group.into_iter().map(|i| i.parse::<usize>().unwrap()).sum()); |
10 | } | 10 | } |
diff --git a/2022/day1/part2/src/main.rs b/2022/day1/part2/src/main.rs index 2a65d1a..62175ab 100644 --- a/2022/day1/part2/src/main.rs +++ b/2022/day1/part2/src/main.rs | |||
@@ -4,7 +4,7 @@ fn main() { | |||
4 | let input: String = include_str!("../../input").to_string(); | 4 | let input: String = include_str!("../../input").to_string(); |
5 | let mut calories: Vec<usize> = Vec::new(); | 5 | let mut calories: Vec<usize> = Vec::new(); |
6 | 6 | ||
7 | for (key, group) in &input.lines().group_by(|line| *line != "") { | 7 | for (key, group) in &input.lines().group_by(|line| line.is_empty()) { |
8 | if key { | 8 | if key { |
9 | calories.push(group.into_iter().map(|i| i.parse::<usize>().unwrap()).sum()); | 9 | calories.push(group.into_iter().map(|i| i.parse::<usize>().unwrap()).sum()); |
10 | } | 10 | } |