day 16 finished
This commit is contained in:
parent
daa8b6b1d0
commit
6f3e94c5d1
6 changed files with 1081 additions and 94 deletions
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
|
|
@ -7,15 +7,15 @@
|
||||||
{
|
{
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Debug executable 'advent2019'",
|
"name": "Debug executable 'advent2022'",
|
||||||
"cargo": {
|
"cargo": {
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
"--bin=advent2019",
|
"--bin=advent2022",
|
||||||
"--package=advent2019"
|
"--package=advent2022"
|
||||||
],
|
],
|
||||||
"filter": {
|
"filter": {
|
||||||
"name": "advent2019",
|
"name": "advent2022",
|
||||||
"kind": "bin"
|
"kind": "bin"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -30,16 +30,16 @@
|
||||||
{
|
{
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Debug unit tests in executable 'advent2019'",
|
"name": "Debug unit tests in executable 'advent2022'",
|
||||||
"cargo": {
|
"cargo": {
|
||||||
"args": [
|
"args": [
|
||||||
"test",
|
"test",
|
||||||
"--no-run",
|
"--no-run",
|
||||||
"--bin=advent2019",
|
"--bin=advent2022",
|
||||||
"--package=advent2019"
|
"--package=advent2022"
|
||||||
],
|
],
|
||||||
"filter": {
|
"filter": {
|
||||||
"name": "advent2019",
|
"name": "advent2022",
|
||||||
"kind": "bin"
|
"kind": "bin"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
"editor.formatOnSave": true
|
"editor.formatOnSave": true,
|
||||||
|
"debug.allowBreakpointsEverywhere": true
|
||||||
}
|
}
|
||||||
|
|
@ -8,7 +8,6 @@ edition = "2021"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
const_format = "0.2.31"
|
const_format = "0.2.31"
|
||||||
itertools = "0.11"
|
itertools = "0.11"
|
||||||
lazy_static = "1.4"
|
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
regex = "1.7"
|
regex = "1.7"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use super::template::{DayTrait, ResultType};
|
use super::template::{DayTrait, ResultType};
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::{iter::zip, num::ParseIntError};
|
use std::{iter::zip, num::ParseIntError};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
@ -72,13 +72,14 @@ struct Monkey {
|
||||||
bad_monkey: usize,
|
bad_monkey: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static MONKEY: Lazy<Regex> = Lazy::new(|| Regex::new(r"Monkey (\d+)").unwrap());
|
||||||
static ref MONKEY: Regex = Regex::new(r"Monkey (\d+)").unwrap();
|
static STARTING: Lazy<Regex> =
|
||||||
static ref STARTING: Regex = Regex::new(r"Starting items: (\d+(?:, \d+)*)").unwrap();
|
Lazy::new(|| Regex::new(r"Starting items: (\d+(?:, \d+)*)").unwrap());
|
||||||
static ref OP: Regex = Regex::new(r"Operation: new = old ([+*] \d+|\* old)").unwrap();
|
static OP: Lazy<Regex> =
|
||||||
static ref TEST: Regex = Regex::new(r"Test: divisible by (\d+)").unwrap();
|
Lazy::new(|| Regex::new(r"Operation: new = old ([+*] \d+|\* old)").unwrap());
|
||||||
static ref NEXT: Regex = Regex::new(r"If (?:true|false): throw to monkey (\d+)").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 {
|
impl Monkey {
|
||||||
fn parse_line<'a>(re: &Regex, line: &'a str) -> Result<&'a str, MonkeyError> {
|
fn parse_line<'a>(re: &Regex, line: &'a str) -> Result<&'a str, MonkeyError> {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use super::template::{DayTrait, ResultType};
|
use super::template::{DayTrait, ResultType};
|
||||||
use crate::common::pos::Pos;
|
use crate::common::pos::Pos;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::{collections::HashSet, num::ParseIntError};
|
use std::{collections::HashSet, num::ParseIntError};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
@ -209,9 +209,8 @@ struct Sensor {
|
||||||
radius: i64,
|
radius: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static SENSOR: Lazy<Regex> =
|
||||||
static ref SENSOR: Regex = Regex::new(r"x=(-?\d+), y=(-?\d+).*x=(-?\d+), y=(-?\d+)").unwrap();
|
Lazy::new(|| Regex::new(r"x=(-?\d+), y=(-?\d+).*x=(-?\d+), y=(-?\d+)").unwrap());
|
||||||
}
|
|
||||||
|
|
||||||
impl Sensor {
|
impl Sensor {
|
||||||
pub fn parse(line: &str) -> Result<(Sensor, Pos<i64>), SensorError> {
|
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