Skip to content

Commit

Permalink
Follow clippy hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrik Rusch committed Nov 8, 2023
1 parent 4ecacdb commit a0fd529
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions aoc16/src/solutions/day11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ pub fn part2(input: &str) -> usize {
}

fn generate_goal(floors: &[HashSet<i32>]) -> HashSet<i32> {
floors.iter().flatten().map(|i| *i).collect()
floors.iter().flatten().copied().collect()
}

fn solve(floors: Vec<HashSet<i32>>, goal: HashSet<i32>) -> usize {
let mut queue = VecDeque::from([(0, State::from(0, floors))]);
let mut visited = HashSet::new();

while let Some((step, state)) = queue.pop_front() {
//println!("{:?}", state.floors);
if state.floors[state.floors.len() - 1] == goal {
return step;
}
Expand Down Expand Up @@ -86,13 +85,13 @@ fn next_states(state: &State) -> Vec<State> {

if level != 0 {
let next_level = level - 1;
if let Some(next_floors) = build_next_floors(&state, next_level, &taken_items) {
if let Some(next_floors) = build_next_floors(state, next_level, &taken_items) {
result.push(State::from(next_level, next_floors));
}
}
if level != state.floors.len() - 1 {
let next_level = level + 1;
if let Some(next_floors) = build_next_floors(&state, next_level, &taken_items) {
if let Some(next_floors) = build_next_floors(state, next_level, &taken_items) {
result.push(State::from(next_level, next_floors));
}
}
Expand Down

0 comments on commit a0fd529

Please sign in to comment.