Skip to content

Commit

Permalink
chore: minor improvements after stream
Browse files Browse the repository at this point in the history
  • Loading branch information
lmammino committed Dec 4, 2023
1 parent 0b2043b commit 2b00172
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions y2023/ex02/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::str::FromStr;

use nom::{
branch::alt, bytes::complete::tag, character::complete::u32, combinator::complete,
multi::separated_list1, IResult,
};
use std::str::FromStr;

#[derive(Debug, PartialEq, Eq)]
struct Game {
Expand Down Expand Up @@ -135,9 +134,8 @@ pub fn part1(input: &str) -> u32 {
}
}

Some(game)
Some(game.id)
})
.map(|game| game.id)
.sum()
}

Expand Down
10 changes: 5 additions & 5 deletions y2023/ex03/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ impl SchematicParser {

pub fn parse(mut self, input: &str) -> Schematic {
for (y, line) in input.lines().enumerate() {
// line resets
if !self.num_buffer.is_empty() {
self.add_new_part(y - 1);
}

for (x, char) in line.char_indices() {
match char {
'0'..='9' => {
Expand All @@ -118,6 +113,11 @@ impl SchematicParser {
}
}
}

// line resets
if !self.num_buffer.is_empty() {
self.add_new_part(y);
}
}

self.schematic
Expand Down

0 comments on commit 2b00172

Please sign in to comment.