Cleaner parsing for day13
This commit is contained in:
parent
2cf47fd7d6
commit
f9c32f0022
|
@ -1,7 +1,7 @@
|
||||||
use aoc_runner_derive::{aoc, aoc_generator};
|
use aoc_runner_derive::{aoc, aoc_generator};
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::{i64 as parse_u64, multispace0};
|
use nom::character::complete::i64 as parse_u64;
|
||||||
use nom::multi::many0;
|
use nom::multi::separated_list0;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
@ -15,7 +15,7 @@ type Input = Vec<Case>;
|
||||||
|
|
||||||
#[aoc_generator(day13)]
|
#[aoc_generator(day13)]
|
||||||
fn parse(input: &str) -> Input {
|
fn parse(input: &str) -> Input {
|
||||||
many0(parse_case)(input).unwrap().1
|
separated_list0(tag("\n\n"), parse_case)(input).unwrap().1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_case(input: &str) -> IResult<&str, Case> {
|
fn parse_case(input: &str) -> IResult<&str, Case> {
|
||||||
|
@ -31,7 +31,6 @@ fn parse_case(input: &str) -> IResult<&str, Case> {
|
||||||
let (input, prize_x) = parse_u64(input)?;
|
let (input, prize_x) = parse_u64(input)?;
|
||||||
let (input, _) = tag(", Y=")(input)?;
|
let (input, _) = tag(", Y=")(input)?;
|
||||||
let (input, prize_y) = parse_u64(input)?;
|
let (input, prize_y) = parse_u64(input)?;
|
||||||
let (input, _) = multispace0(input)?;
|
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
input,
|
input,
|
||||||
|
|
Loading…
Reference in New Issue