Skip to content

Commit 30c5aa6

Browse files
committed
feat(11/2025): solve second part for example
1 parent 29d9c39 commit 30c5aa6

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

src/solutions/year2025/day11.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ pub struct Day11;
66

77
const LABEL_YOU: &str = "you";
88
const LABEL_OUT: &str = "out";
9+
const LABEL_SVR: &str = "svr";
10+
const LABEL_DAC: &str = "dac";
11+
const LABEL_FFT: &str = "fft";
912

1013
impl Solution for Day11 {
1114
fn part_one(&self, input: &str) -> String {
@@ -15,8 +18,16 @@ impl Solution for Day11 {
1518
all_paths.paths(LABEL_YOU, LABEL_OUT).len().to_string()
1619
}
1720

18-
fn part_two(&self, _input: &str) -> String {
19-
String::from("0")
21+
fn part_two(&self, input: &str) -> String {
22+
let graph = self.parse(input);
23+
let all_paths: AllPaths<&str> = (&graph).into();
24+
25+
all_paths
26+
.paths(LABEL_SVR, LABEL_OUT)
27+
.iter()
28+
.filter(|path| path.contains(&LABEL_DAC) && path.contains(&LABEL_FFT))
29+
.count()
30+
.to_string()
2031
}
2132
}
2233

@@ -42,7 +53,7 @@ mod tests {
4253
use crate::solutions::year2025::day11::Day11;
4354
use crate::solutions::Solution;
4455

45-
const EXAMPLE: &str = r#"aaa: you hhh
56+
const EXAMPLE_PART_ONE: &str = r#"aaa: you hhh
4657
you: bbb ccc
4758
bbb: ddd eee
4859
ccc: ddd eee fff
@@ -55,6 +66,25 @@ iii: out"#;
5566

5667
#[test]
5768
fn part_one_example_test() {
58-
assert_eq!("5", Day11.part_one(EXAMPLE));
69+
assert_eq!("5", Day11.part_one(EXAMPLE_PART_ONE));
70+
}
71+
72+
const EXAMPLE_PART_TWO: &str = r#"svr: aaa bbb
73+
aaa: fft
74+
fft: ccc
75+
bbb: tty
76+
tty: ccc
77+
ccc: ddd eee
78+
ddd: hub
79+
hub: fff
80+
eee: dac
81+
dac: fff
82+
fff: ggg hhh
83+
ggg: out
84+
hhh: out"#;
85+
86+
#[test]
87+
fn part_two_example_test() {
88+
assert_eq!("2", Day11.part_two(EXAMPLE_PART_TWO));
5989
}
6090
}

0 commit comments

Comments
 (0)