Wasnt working with the original input file. Crashed with the new line.
This commit is contained in:
parent
1a87d8c6b3
commit
b90110ef0f
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue