I hadn't originally intended to do this in rust however I decided to try it as a scoping exercise and I realised that I had enough knowledge and ability to do it in rust. It was an interesting project and as usual for me with rust I learned from what I built and shored up other knowledge I already had. I admit to finding most coding tests a bit boring but I found working on this quite interesting, it helps that I like Space and Mars Rover related stuff; I don't even normally do write-ups but I felt in this case I had to.
The bit I enjoyed working on the most was the rover_commands
module, whilst it isn't
building a parsing grammar it felt a bit like it and was just interesting overall to work on.
It was also quite vindicating as it proved my idea worked.
I'm also quite proud with how the execution of the commands works as it ended up with a clean looking chunk
of code in fn main()
.
The executable can be used in two ways:
- Load file:
cargo run rover.commands
- withrover.commands
being a text file containing the commands to be executed - Manual Mode:
cargo run
- this allows you to manually enter commands pressing enter between commands, to finish you you have toCTRL-C
followed byenter
, this is a bug I'm not sure how to resolve
The first command run regardless of usage method needs to be the grid size command x y
, replacing x y
with the max bounds of the grid.
The provided test case is in the rover.commands
file.
Entering Malformed instructions will crash the app