WIP aoc 2015 day 9

This commit is contained in:
2023-12-04 08:46:18 +01:00
parent 1910caab51
commit 2a60712f44
3 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
use nom::{
bytes::complete::tag,
character::complete::{alpha1, i64, multispace1},
multi::separated_list1,
sequence::tuple,
IResult,
};
fn parse_input(input: &str) -> IResult<&str, Vec<(String, String, i64)>> {
let (input, result) = separated_list1(
multispace1,
tuple((alpha1, tag(" to "), alpha1, tag(" = "), i64))
.map(|(from, _, to, _, distance)| (from.to_string(), to.to_string(), distance)),
)(input)?;
Ok((input, result))
}
fn solve_first(distances: &[(String, String, i64)]) -> i64 {
todo!()
}
fn main() {
println!("Hello, Patrick!");
let input_txt = include_str!("../input.txt");
let (_, distances) = parse_input(input_txt).unwrap();
let first_result = solve_first(&distances[..]);
println!("The shortest route is {}", first_result);
}