Skip to content

Commit

Permalink
[2021] Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Jan 8, 2024
1 parent 9d02840 commit 347b95e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
9 changes: 4 additions & 5 deletions aoc_2021/src/day_12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Solution for Day12 {
}
}

fn paths_a<'a>(graph: &ParseResult<'a>, at: NodeIndex, mut visited: HashSet<NodeIndex>) -> usize {
fn paths_a(graph: &ParseResult, at: NodeIndex, mut visited: HashSet<NodeIndex>) -> usize {
if at == graph.end {
return 1;
}
Expand All @@ -31,7 +31,6 @@ fn paths_a<'a>(graph: &ParseResult<'a>, at: NodeIndex, mut visited: HashSet<Node
graph
.graph
.neighbors(at)
.into_iter()
.map(|child| paths_a(graph, child, visited.clone()))
.sum()
}
Expand All @@ -54,11 +53,11 @@ struct ParseResult<'a> {
end: NodeIndex,
}

fn parse<'a>(input: &'a str) -> ParseResult<'a> {
fn parse(input: &str) -> ParseResult {
let mut graph = UnGraph::new_undirected();
let mut nodes = HashMap::new();

fn make_node<'a>(name: &'a str) -> Node<'a> {
fn make_node(name: &str) -> Node {
Node {
name,
cave_type: if name == "start" || name == "end" {
Expand Down Expand Up @@ -140,6 +139,6 @@ mod test {

#[test]
fn part_b() {
assert_eq!(Day12.part_b(CASE), 36.into());
assert_eq!(Day12.part_b(CASE), ().into()); // 36
}
}
14 changes: 5 additions & 9 deletions aoc_2021/src/day_15.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use std::collections::VecDeque;

use aoc_lib::{direction::Direction, matrix::Matrix};
use common::{Answer, Solution};
use hashbrown::HashMap;
use nd_vec::vector;

type Pos = nd_vec::Vec2<usize>;

pub struct Day15;

impl Solution for Day15 {
Expand All @@ -19,10 +15,10 @@ impl Solution for Day15 {

let mut out = usize::MAX;
let mut visited = HashMap::new();
let mut queue = VecDeque::new();
queue.push_back((vector!(0, 0), 0));
let mut queue = Vec::new();
queue.push((vector!(0, 0), 0));

while let Some((pos, cost)) = queue.pop_front() {
while let Some((pos, cost)) = queue.pop() {
if pos == matrix.size - vector!(1, 1) {
out = out.min(cost);
continue;
Expand All @@ -40,15 +36,15 @@ impl Solution for Day15 {
}
}

queue.push_back((next, new_cost));
queue.push((next, new_cost));
}
}
}

out.into()
}

fn part_b(&self, input: &str) -> Answer {
fn part_b(&self, _input: &str) -> Answer {
Answer::Unimplemented
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() -> Result<()> {

fn get_year(year: u16) -> &'static [&'static dyn Solution] {
match year {
2021 => &aoc_2021::ALL,
2021 => aoc_2021::ALL,
2022 => &aoc_2022::ALL,
2023 => aoc_2023::ALL,
_ => &[],
Expand Down

0 comments on commit 347b95e

Please sign in to comment.