the_toy_robot
所属分类:编程语言基础
开发工具:Elixir
文件大小:0KB
下载次数:0
上传日期:2019-09-14 21:41:20
上 传 者:
sh-1993
说明: 我对玩具机器人编程挑战的想法。,
(My thoughts on The Toy Robot programming challenge.,)
文件列表:
.formatter.exs (97, 2019-09-14)
lib/ (0, 2019-09-14)
lib/the_toy_robot/ (0, 2019-09-14)
lib/the_toy_robot/cli.ex (453, 2019-09-14)
lib/the_toy_robot/simulation.ex (1638, 2019-09-14)
mix.exs (666, 2019-09-14)
test/ (0, 2019-09-14)
test/cli_test.exs (519, 2019-09-14)
test/simulation_test.exs (2921, 2019-09-14)
test/support/ (0, 2019-09-14)
test/support/fixtures/ (0, 2019-09-14)
test/support/fixtures/commands.txt (49, 2019-09-14)
test/test_helper.exs (15, 2019-09-14)
the_toy_robot (1006870, 2019-09-14)
# The Toy Robot
This code is my rendition of the popular interviewing exercise that I learned about from Ryan Bigg's book:
https://leanpub.com/elixir-toyrobot
I would talk about these aspects of it in an interview:
* My primary solution is under 50 lines of code, not because I golfed it, but because I tried to throw the right amount of solution at a problem of this size
* I wrote a pipeline of transformations
* This is a trival state machine
* I'm doing very little work here, outside of pattern matching
* The table doesn't feel like a data concept as specified, so I chose just to track robot state
* I always prefer to handle individual instructions, then add a wrapper that performs the required handling of many instructions
* I considered generating all possible `{x, y, f}, "MOVE"` function heads, but didn't because it makes the code uglier
* I considered property testing, but the code is so small that I could basically exhaustively unit test it
* I paid careful attention to the interplay of `:async` tests and `capture_io/1`
* I have purposefully avoided the use of processes and the OTP here, because I don't want to complicate this completely synchronous exercise
近期下载者:
相关文件:
收藏者: