2020-10-11 18:25:42 +02:00
|
|
|
enum Orientation {
|
2020-10-06 23:25:17 +02:00
|
|
|
N,
|
|
|
|
E,
|
|
|
|
S,
|
|
|
|
W,
|
2020-10-06 20:34:48 +02:00
|
|
|
}
|
2020-10-06 23:25:17 +02:00
|
|
|
|
2020-10-11 18:25:42 +02:00
|
|
|
enum Instruction {
|
2020-10-06 23:28:59 +02:00
|
|
|
L,
|
|
|
|
R,
|
|
|
|
F,
|
|
|
|
}
|
|
|
|
|
2020-10-11 20:10:17 +02:00
|
|
|
fn parse_orientation(c: char) -> Result<Orientation, &'static str> {
|
2020-10-11 18:27:39 +02:00
|
|
|
match c {
|
2020-10-11 20:10:17 +02:00
|
|
|
'N' => Ok(Orientation::N),
|
|
|
|
'E' => Ok(Orientation::E),
|
|
|
|
'S' => Ok(Orientation::S),
|
|
|
|
'W' => Ok(Orientation::W),
|
|
|
|
_ => Err("Invalid character, does not match any orientations"),
|
2020-10-11 18:27:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 20:10:17 +02:00
|
|
|
fn parse_instruction(c: char) -> Result<Instruction, &'static str> {
|
2020-10-11 18:31:56 +02:00
|
|
|
match c {
|
2020-10-11 20:10:17 +02:00
|
|
|
'L' => Ok(Instruction::L),
|
|
|
|
'R' => Ok(Instruction::R),
|
|
|
|
'F' => Ok(Instruction::F),
|
|
|
|
_ => Err("Invalid character, does not match any instructions"),
|
2020-10-11 18:31:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 15:14:20 +02:00
|
|
|
fn main() {
|
|
|
|
let file_data = include_str!("../two_robots.txt");
|
|
|
|
}
|