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,7 +1,9 @@
[package]
name = "day10"
version = "0.1.0"
edition = "2021"
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

View File

@@ -1,3 +1,5 @@
#![warn(clippy::all, clippy::pedantic)]
use std::fs::File;
use std::io::{prelude::*, BufReader};
use std::str;
@@ -7,17 +9,17 @@ fn main() -> std::io::Result<()> {
let file = File::open("input")?;
let reader = BufReader::new(file);
let mut part1: Vec<i32> = Vec::new();
let mut part1: Vec<_> = Vec::new();
let mut part2 = [[b'.'; 40]; 6];
let mut x_reg = 1;
let mut pc = 0;
let mut pc = 0_u32;
reader.lines().for_each(|line| {
let line = line.unwrap();
let op = match line.split(' ').collect::<Vec<_>>()[..] {
["addx", x] => Some(x.parse::<i32>().unwrap()),
["addx", x] => Some(x.parse::<u32>().unwrap()),
["noop"] => None,
_ => panic!("invalid command: {}", line),
_ => panic!("invalid command: {line}"),
};
let steps = if op.is_some() { 2 } else { 1 };
for i in 0..steps {
@@ -38,7 +40,7 @@ fn main() -> std::io::Result<()> {
}
});
println!("Part 1: {}", part1.iter().sum::<i32>());
println!("Part 1: {}", part1.iter().sum::<u32>());
for row in part2 {
println!("Part 2: {}", str::from_utf8(&row).unwrap());
}