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> {
|
pub fn parse_input(input: &str) -> Vec<Move> {
|
||||||
input
|
input
|
||||||
.split(", ")
|
.lines()
|
||||||
.map(|item| {
|
.map(|line| {
|
||||||
let num = item[1..].parse::<u16>().unwrap();
|
line.split(", ")
|
||||||
match &item[0..1] {
|
.map(|item| {
|
||||||
"L" => Move::Left(num),
|
let num = item[1..].parse::<u16>().unwrap();
|
||||||
"R" => Move::Right(num),
|
match &item[0..1] {
|
||||||
_ => panic!("invalid"),
|
"L" => Move::Left(num),
|
||||||
}
|
"R" => Move::Right(num),
|
||||||
|
_ => panic!("invalid"),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<Move>>()
|
||||||
})
|
})
|
||||||
|
.flatten()
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue