Skip to content

Commit

Permalink
minor optimization - check horizontal first
Browse files Browse the repository at this point in the history
  • Loading branch information
BakerNet committed Dec 13, 2023
1 parent e21a825 commit 059f22d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bin/13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ fn find_horizontal_reflection(map: &Vec<Vec<char>>, type2: bool) -> Option<usize

fn find_reflection_value(map: &Vec<&str>, type2: bool) -> usize {
let map = map.iter().map(|s| s.chars().collect()).collect();
if let Some(x) = find_vertical_reflection(&map, type2) {
return x + 1;
}
if let Some(x) = find_horizontal_reflection(&map, type2) {
return (x + 1) * 100;
}
if let Some(x) = find_vertical_reflection(&map, type2) {
return x + 1;
}
panic!("No reflection found: type 2 is {} - {:?}", type2, map);
}

Expand Down

0 comments on commit 059f22d

Please sign in to comment.