WIP aoc 2015 day 9
This commit is contained in:
33
advent_of_code/2015/9/src/main.rs
Normal file
33
advent_of_code/2015/9/src/main.rs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user