Skip to content

Commit 5d2209a

Browse files
committed
refactor(07/2025): extract run method as a foundation for part two
1 parent ea94692 commit 5d2209a

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/solutions/year2025/day07.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ pub struct Day07;
1313

1414
impl Solution for Day07 {
1515
fn part_one(&self, input: &str) -> String {
16+
let (splits, _) = self.run(input);
17+
18+
splits.to_string()
19+
}
20+
21+
fn part_two(&self, _input: &str) -> String {
22+
String::from("0")
23+
}
24+
}
25+
26+
impl Day07 {
27+
fn parse(&self, input: &str) -> Grid<char> {
28+
let without_redundant_lines = input.lines().step_by(2).collect::<Vec<_>>().join("\n");
29+
30+
Grid::from(without_redundant_lines.as_str())
31+
}
32+
33+
fn run(&self, input: &str) -> (u16, u16) {
1634
let grid = self.parse(input);
1735
let rows_range = grid.rows_range();
1836
let start = grid.get_first_position(&START).unwrap();
@@ -21,7 +39,7 @@ impl Solution for Day07 {
2139

2240
let mut finished_beams: Vec<Beam> = Vec::new();
2341
let mut current_beams: VecDeque<Beam> = VecDeque::from(vec![start.into()]);
24-
let mut splits = 0;
42+
let mut splits = 0u16;
2543

2644
while let Some(current_beam) = current_beams.pop_front() {
2745
if finished_beams
@@ -53,19 +71,7 @@ impl Solution for Day07 {
5371
current_beams.push_front(down);
5472
}
5573

56-
splits.to_string()
57-
}
58-
59-
fn part_two(&self, _input: &str) -> String {
60-
String::from("0")
61-
}
62-
}
63-
64-
impl Day07 {
65-
fn parse(&self, input: &str) -> Grid<char> {
66-
let without_redundant_lines = input.lines().step_by(2).collect::<Vec<_>>().join("\n");
67-
68-
Grid::from(without_redundant_lines.as_str())
74+
(splits, 0)
6975
}
7076
}
7177

0 commit comments

Comments
 (0)