Day 11 clippy lint
This commit is contained in:
parent
197fc4dc2c
commit
b88d1d2a37
@ -2,14 +2,12 @@ use std::{
|
|||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
fmt::{Debug, Error, Formatter},
|
fmt::{Debug, Error, Formatter},
|
||||||
num::ParseIntError,
|
|
||||||
ops::{Index, IndexMut},
|
ops::{Index, IndexMut},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use aoc_runner_derive::{aoc, aoc_generator};
|
use aoc_runner_derive::aoc;
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
struct Image {
|
struct Image {
|
||||||
width: usize,
|
width: usize,
|
||||||
@ -23,7 +21,6 @@ impl Image {
|
|||||||
where
|
where
|
||||||
F: Fn(u8) -> u8,
|
F: Fn(u8) -> u8,
|
||||||
{
|
{
|
||||||
println!("flash @ ({}, {})", x, y);
|
|
||||||
if x > 0 {
|
if x > 0 {
|
||||||
self[(x - 1, y)] = func(self[(x - 1, y)]);
|
self[(x - 1, y)] = func(self[(x - 1, y)]);
|
||||||
if y > 0 {
|
if y > 0 {
|
||||||
@ -58,7 +55,6 @@ impl Image {
|
|||||||
loop {
|
loop {
|
||||||
let mut flashes = 0;
|
let mut flashes = 0;
|
||||||
// Apply the effect of a flash on neighbors
|
// Apply the effect of a flash on neighbors
|
||||||
dbg!(&self);
|
|
||||||
let mut need_to_flash = Vec::new();
|
let mut need_to_flash = Vec::new();
|
||||||
for y in 0..self.height {
|
for y in 0..self.height {
|
||||||
for x in 0..self.width {
|
for x in 0..self.width {
|
||||||
@ -177,7 +173,7 @@ fn part2(input: &str) -> Result<usize> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use pretty_assertions::{assert_eq, assert_ne};
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_part1() -> Result<()> {
|
fn test_part1() -> Result<()> {
|
||||||
@ -404,141 +400,6 @@ mod tests {
|
|||||||
.parse()?;
|
.parse()?;
|
||||||
let step10_flashes = 204;
|
let step10_flashes = 204;
|
||||||
|
|
||||||
let step20: Image = r#"
|
|
||||||
3936556452
|
|
||||||
5686556806
|
|
||||||
4496555690
|
|
||||||
4448655580
|
|
||||||
4456865570
|
|
||||||
5680086577
|
|
||||||
7000009896
|
|
||||||
0000000344
|
|
||||||
6000000364
|
|
||||||
4600009543
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step30: Image = r#"
|
|
||||||
0643334118
|
|
||||||
4253334611
|
|
||||||
3374333458
|
|
||||||
2225333337
|
|
||||||
2229333338
|
|
||||||
2276733333
|
|
||||||
2754574565
|
|
||||||
5544458511
|
|
||||||
9444447111
|
|
||||||
7944446119
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step40: Image = r#"
|
|
||||||
6211111981
|
|
||||||
0421111119
|
|
||||||
0042111115
|
|
||||||
0003111115
|
|
||||||
0003111116
|
|
||||||
0065611111
|
|
||||||
0532351111
|
|
||||||
3322234597
|
|
||||||
2222222976
|
|
||||||
2222222762
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step50: Image = r#"
|
|
||||||
9655556447
|
|
||||||
4865556805
|
|
||||||
4486555690
|
|
||||||
4458655580
|
|
||||||
4574865570
|
|
||||||
5700086566
|
|
||||||
6000009887
|
|
||||||
8000000533
|
|
||||||
6800000633
|
|
||||||
5680000538
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step60: Image = r#"
|
|
||||||
2533334200
|
|
||||||
2743334640
|
|
||||||
2264333458
|
|
||||||
2225333337
|
|
||||||
2225333338
|
|
||||||
2287833333
|
|
||||||
3854573455
|
|
||||||
1854458611
|
|
||||||
1175447111
|
|
||||||
1115446111
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step70: Image = r#"
|
|
||||||
8211111164
|
|
||||||
0421111166
|
|
||||||
0042111114
|
|
||||||
0004211115
|
|
||||||
0000211116
|
|
||||||
0065611111
|
|
||||||
0532351111
|
|
||||||
7322235117
|
|
||||||
5722223475
|
|
||||||
4572222754
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step80: Image = r#"
|
|
||||||
1755555697
|
|
||||||
5965555609
|
|
||||||
4486555680
|
|
||||||
4458655580
|
|
||||||
4570865570
|
|
||||||
5700086566
|
|
||||||
7000008666
|
|
||||||
0000000990
|
|
||||||
0000000800
|
|
||||||
0000000000
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step90: Image = r#"
|
|
||||||
7433333522
|
|
||||||
2643333522
|
|
||||||
2264333458
|
|
||||||
2226433337
|
|
||||||
2222433338
|
|
||||||
2287833333
|
|
||||||
2854573333
|
|
||||||
4854458333
|
|
||||||
3387779333
|
|
||||||
3333333333
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step100: Image = r#"
|
|
||||||
0397666866
|
|
||||||
0749766918
|
|
||||||
0053976933
|
|
||||||
0004297822
|
|
||||||
0004229892
|
|
||||||
0053222877
|
|
||||||
0532222966
|
|
||||||
9322228966
|
|
||||||
7922286866
|
|
||||||
6789998766
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
im.step();
|
im.step();
|
||||||
assert_eq!(im, step1, "step1");
|
assert_eq!(im, step1, "step1");
|
||||||
im.step();
|
im.step();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user