day 16 finished
This commit is contained in:
parent
daa8b6b1d0
commit
6f3e94c5d1
6 changed files with 1081 additions and 94 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use super::template::{DayTrait, ResultType};
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
use std::{iter::zip, num::ParseIntError};
|
||||
use thiserror::Error;
|
||||
|
|
@ -72,13 +72,14 @@ struct Monkey {
|
|||
bad_monkey: usize,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref MONKEY: Regex = Regex::new(r"Monkey (\d+)").unwrap();
|
||||
static ref STARTING: Regex = Regex::new(r"Starting items: (\d+(?:, \d+)*)").unwrap();
|
||||
static ref OP: Regex = Regex::new(r"Operation: new = old ([+*] \d+|\* old)").unwrap();
|
||||
static ref TEST: Regex = Regex::new(r"Test: divisible by (\d+)").unwrap();
|
||||
static ref NEXT: Regex = Regex::new(r"If (?:true|false): throw to monkey (\d+)").unwrap();
|
||||
}
|
||||
static MONKEY: Lazy<Regex> = Lazy::new(|| Regex::new(r"Monkey (\d+)").unwrap());
|
||||
static STARTING: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"Starting items: (\d+(?:, \d+)*)").unwrap());
|
||||
static OP: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"Operation: new = old ([+*] \d+|\* old)").unwrap());
|
||||
static TEST: Lazy<Regex> = Lazy::new(|| Regex::new(r"Test: divisible by (\d+)").unwrap());
|
||||
static NEXT: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"If (?:true|false): throw to monkey (\d+)").unwrap());
|
||||
|
||||
impl Monkey {
|
||||
fn parse_line<'a>(re: &Regex, line: &'a str) -> Result<&'a str, MonkeyError> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use super::template::{DayTrait, ResultType};
|
||||
use crate::common::pos::Pos;
|
||||
use itertools::Itertools;
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
use std::{collections::HashSet, num::ParseIntError};
|
||||
use thiserror::Error;
|
||||
|
|
@ -209,9 +209,8 @@ struct Sensor {
|
|||
radius: i64,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref SENSOR: Regex = Regex::new(r"x=(-?\d+), y=(-?\d+).*x=(-?\d+), y=(-?\d+)").unwrap();
|
||||
}
|
||||
static SENSOR: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"x=(-?\d+), y=(-?\d+).*x=(-?\d+), y=(-?\d+)").unwrap());
|
||||
|
||||
impl Sensor {
|
||||
pub fn parse(line: &str) -> Result<(Sensor, Pos<i64>), SensorError> {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue