Address cargo clippy
This commit is contained in:
parent
b83d6f081d
commit
7a3a9c096a
@ -114,7 +114,7 @@ impl Debug for Edge {
|
|||||||
// to each node. This implementation isn't memory-efficient as it may leave duplicate
|
// to each node. This implementation isn't memory-efficient as it may leave duplicate
|
||||||
// nodes in the queue. It also uses `usize::MAX` as a sentinel value,
|
// nodes in the queue. It also uses `usize::MAX` as a sentinel value,
|
||||||
// for a simpler implementation.
|
// for a simpler implementation.
|
||||||
fn shortest_path(adj_list: &Vec<Vec<Edge>>, start: usize, goal: usize) -> Option<usize> {
|
fn shortest_path(adj_list: &[Vec<Edge>], start: usize, goal: usize) -> Option<usize> {
|
||||||
// dist[node] = current shortest distance from `start` to `node`
|
// dist[node] = current shortest distance from `start` to `node`
|
||||||
let mut dist: Vec<_> = (0..adj_list.len()).map(|_| usize::MAX).collect();
|
let mut dist: Vec<_> = (0..adj_list.len()).map(|_| usize::MAX).collect();
|
||||||
|
|
||||||
|
|||||||
@ -11,18 +11,18 @@ fn hex(b: &u8) -> u8 {
|
|||||||
|
|
||||||
fn sum_version(packet: &Packet) -> u64 {
|
fn sum_version(packet: &Packet) -> u64 {
|
||||||
fn sum_packets(packets: &[Packet]) -> u64 {
|
fn sum_packets(packets: &[Packet]) -> u64 {
|
||||||
packets.iter().map(|p| sum_version(p)).sum()
|
packets.iter().map(sum_version).sum()
|
||||||
}
|
}
|
||||||
packet.version as u64
|
packet.version as u64
|
||||||
+ match &packet.packet_type {
|
+ match &packet.packet_type {
|
||||||
PacketType::Sum(packets) => sum_packets(&packets),
|
PacketType::Sum(packets) => sum_packets(packets),
|
||||||
PacketType::Product(packets) => sum_packets(&packets),
|
PacketType::Product(packets) => sum_packets(packets),
|
||||||
PacketType::Minimum(packets) => sum_packets(&packets),
|
PacketType::Minimum(packets) => sum_packets(packets),
|
||||||
PacketType::Maximum(packets) => sum_packets(&packets),
|
PacketType::Maximum(packets) => sum_packets(packets),
|
||||||
PacketType::Literal(_) => 0,
|
PacketType::Literal(_) => 0,
|
||||||
PacketType::GreaterThan(packets) => sum_packets(&packets),
|
PacketType::GreaterThan(packets) => sum_packets(packets),
|
||||||
PacketType::LessThan(packets) => sum_packets(&packets),
|
PacketType::LessThan(packets) => sum_packets(packets),
|
||||||
PacketType::Equal(packets) => sum_packets(&packets),
|
PacketType::Equal(packets) => sum_packets(packets),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ impl<'a> Parser<'a> {
|
|||||||
let v = (self.tmp >> self.tmp_len) & mask;
|
let v = (self.tmp >> self.tmp_len) & mask;
|
||||||
|
|
||||||
let mask = (1 << self.tmp_len) - 1;
|
let mask = (1 << self.tmp_len) - 1;
|
||||||
self.tmp = self.tmp & mask;
|
self.tmp &= mask;
|
||||||
|
|
||||||
//println!( " END n {0} tmp 0b{2:b} len {3} v 0b{1:00$b} ", n, v, self.tmp, self.tmp_len);
|
//println!( " END n {0} tmp 0b{2:b} len {3} v 0b{1:00$b} ", n, v, self.tmp, self.tmp_len);
|
||||||
v as u64
|
v as u64
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use advent::prelude::*;
|
use advent::prelude::*;
|
||||||
use aoc_runner_derive::{aoc, aoc_generator};
|
use aoc_runner_derive::aoc;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Target {
|
struct Target {
|
||||||
@ -43,11 +43,11 @@ impl FromStr for Target {
|
|||||||
let y = &parts[3][2..];
|
let y = &parts[3][2..];
|
||||||
let (x_min, x_max) = x
|
let (x_min, x_max) = x
|
||||||
.split_once("..")
|
.split_once("..")
|
||||||
.and_then(|(min, max)| Some((min.parse().unwrap(), max.parse().unwrap())))
|
.map(|(min, max)| (min.parse().unwrap(), max.parse().unwrap()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let (y_min, y_max) = y
|
let (y_min, y_max) = y
|
||||||
.split_once("..")
|
.split_once("..")
|
||||||
.and_then(|(min, max)| Some((min.parse().unwrap(), max.parse().unwrap())))
|
.map(|(min, max)| (min.parse().unwrap(), max.parse().unwrap()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Ok(Target {
|
Ok(Target {
|
||||||
|
|||||||
@ -161,8 +161,7 @@ impl MarkerBoard {
|
|||||||
let m = self.0;
|
let m = self.0;
|
||||||
|
|
||||||
// Bingo horizontally
|
// Bingo horizontally
|
||||||
false
|
(m & h == h)
|
||||||
|| (m & h == h)
|
|
||||||
|| ((m >> 5 & h) == h)
|
|| ((m >> 5 & h) == h)
|
||||||
|| ((m >> 10 & h) == h)
|
|| ((m >> 10 & h) == h)
|
||||||
|| ((m >> 15 & h) == h)
|
|| ((m >> 15 & h) == h)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user