adding workspace and clippy watnings

This commit is contained in:
Dylan Thies
2023-08-28 18:37:44 -04:00
parent e970fd9873
commit 8a233f61bf
24 changed files with 149 additions and 107 deletions

View File

@@ -1,13 +1,15 @@
[package]
name = "day11"
version = "0.1.0"
edition = "2021"
description = "AOC 2022 Day 11"
version.workspace = true
edition.workspace = true
authors.workspace = true
repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
derive-getters = "0.3.0"
itertools = "0.11.0"
log = "0.4.20"
nom = "7.1.3"
derive-getters.workspace = true
itertools.workspace = true
log.workspace = true
nom.workspace = true

View File

@@ -1,6 +1,8 @@
#![warn(clippy::all, clippy::pedantic)]
use derive_getters::Getters;
use itertools::Itertools;
use log::{debug, trace};
use nom::{
branch::alt,
bytes::complete::tag,
@@ -10,7 +12,6 @@ use nom::{
sequence::{delimited, preceded},
IResult, Parser,
};
use log::{debug, trace};
use std::{
collections::VecDeque, error, fmt::Display, fs::File, io::Read, num::ParseIntError,
str::FromStr,
@@ -150,8 +151,12 @@ impl Test {
let (input, true_to) = match preceded(
tag("If true: throw to monkey "),
nom::character::complete::u64.map(|x| usize::try_from(x).unwrap()),
)(input){
Err(e) => {println!("{e:?}"); Err(e)},
)(input)
{
Err(e) => {
println!("{e:?}");
Err(e)
}
x => x,
}?;
trace!("parse test 4");
@@ -186,7 +191,7 @@ impl Ape {
}
pub fn inspect(&mut self, relief: bool) -> Option<u64> {
let relief: u64 = if relief {3} else {1};
let relief: u64 = if relief { 3 } else { 1 };
let item = self.items.pop_front()?;
self.inspected += 1;
Some(self.operation.do_op(item) / relief)
@@ -331,7 +336,7 @@ fn main() {
//game 1
for _ in 0..20 {
for i in 0..monkeys.len() {
while let Some( item) = monkeys[i].inspect(true){
while let Some(item) = monkeys[i].inspect(true) {
let throw_to = monkeys[i].throw(item);
monkeys[throw_to].catch(item);
}
@@ -348,7 +353,10 @@ fn main() {
.product::<u64>();
println!("Part 1: {val}");
let magic = monkeys_game2.iter().map(|x| x.test().divisor()).product::<u64>();
let magic = monkeys_game2
.iter()
.map(|x| x.test().divisor())
.product::<u64>();
for _ in 0..10_000 {
for i in 0..monkeys_game2.len() {