Wasnt working with the original input file. Crashed with the new line.

This commit is contained in:
Pedro de Oliveira 2023-05-05 20:58:24 +01:00
parent 1a87d8c6b3
commit b90110ef0f
1 changed files with 13 additions and 8 deletions

View File

@ -20,15 +20,20 @@ struct Position {
pub fn parse_input(input: &str) -> Vec<Move> {
input
.split(", ")
.map(|item| {
let num = item[1..].parse::<u16>().unwrap();
match &item[0..1] {
"L" => Move::Left(num),
"R" => Move::Right(num),
_ => panic!("invalid"),
}
.lines()
.map(|line| {
line.split(", ")
.map(|item| {
let num = item[1..].parse::<u16>().unwrap();
match &item[0..1] {
"L" => Move::Left(num),
"R" => Move::Right(num),
_ => panic!("invalid"),
}
})
.collect::<Vec<Move>>()
})
.flatten()
.collect()
}