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 nom::bytes::complete::tag; | ||||
| use nom::character::complete::{i64 as parse_u64, multispace0}; | ||||
| use nom::multi::many0; | ||||
| use nom::character::complete::i64 as parse_u64; | ||||
| use nom::multi::separated_list0; | ||||
| use nom::IResult; | ||||
| 
 | ||||
| #[derive(Debug, Clone, Copy)] | ||||
| @ -15,7 +15,7 @@ type Input = Vec<Case>; | ||||
| 
 | ||||
| #[aoc_generator(day13)] | ||||
| 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> { | ||||
| @ -31,7 +31,6 @@ fn parse_case(input: &str) -> IResult<&str, Case> { | ||||
|     let (input, prize_x) = parse_u64(input)?; | ||||
|     let (input, _) = tag(", Y=")(input)?; | ||||
|     let (input, prize_y) = parse_u64(input)?; | ||||
|     let (input, _) = multispace0(input)?; | ||||
| 
 | ||||
|     Ok(( | ||||
|         input, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jan-Bulthuis
						Jan-Bulthuis