Wizards 'n shit
An implementation in Elixir of the Toy Robot coding challenge
The Toy Alchemist
is like the Toy Robot
but works with "potions" instead of "commands" here in Elixir land.
This was created as a demo project to be created during any "Learn Elixir" workshop. It can be used to achieve a better understanding of how the Elixir language functions and can help grep more functional programming concepts.
The workshop is built to be very collaborative and the "correct answer" could be far different from this one. This is just one of many but I felt this implementation was very approachable.
- Install the depedencies
mix deps.get
The Toy Alchemist can be currently ran as a CLI application within the terminal after the application is compiled.
> ./alchemist [FILE_PATH]
An example can be the following:
> ./alchemist ~/sorcery/potions.txt
The file path specied can be just any text file with a potion listed on each line. An example of a potion file may look like this:
PLACE 1,2,NORTH
MOVE
LEFT
MOVE
RIGHT
MOVE
MOVE
LEFT
REPORT
All potions are ignored until an alchemist is placed at a valid location within the "table". Anytime a REPORT
potion is encountered, it displays the current location of the alchemist.
Here are the currently supported potions.
MOVE
- Moves theAlchemist
one space in the direction they are facing. It does not perform the move if the Alchemist can fall off of the Elixir Table.LEFT
- Turns theAlchemist
to the left of the direction they are facing.RIGHT
- Turns theAlchemist
to the right of the direction they are facing.PLACE
- Places a newAlchemist
at the specified position and facing the specified direction.REPORT
- Reports on the position and direction of theAlchemist
.
You can run the tasks with the standard mix command:
mix test
- Clone the repository
git clone https://github.com/jwright/toy_alchemist
- Create a feature branch
git checkout -b my-awesome-feature
- Codez!
- Commit your changes (small commits please)
- Push your new branch
git push origin my-awesome-feature
- Create a pull request
gh pr create