Code Monkey home page Code Monkey logo

rb-martian-robots's Introduction

Usage

Running Tests

You need pytest on your system to run the tests. There are no non-standard library dependencies, so you can simply pip3 install pytest or equivalent on your system, or set up a virtual environment and install the requirements.txt via pip3 install -r requirements.txt.

To run tests run pytest.

Running Sample Data Files

You can run the sample data by calling the script e.g. python3 main.py sample_data.txt, passing the file you want to process as the first positional parameter.

Running Sample Data Online

You can also run sample data from the web with a simple lambda interface at https://f55xysqwn6dfq3ry55d4jk52lu0mzrgr.lambda-url.us-east-1.on.aws/. The interface is all contained in lambda_handler and has a text area you can paste your data to process.

Deployment

You can run this lamdba yourself by copying the entire main as the lambda function code with lambda_handler (the default name anyway) as the entry point. There are no external dependencies so packaging is not necessary.

Solution Discussion

The approach taken was to let the world contain the logic to run the simulation, represented by the class World. The robots (class Robot) act as a container for coordinates and direction. The world owns the interface to run the simulation, and tracks where robots fall off the grid. The World class is then wrapped to expose it to different interfaces such as a CLI and a small lambda based web interface.

Design Decisions

Coding Language

After reviewing the project statement Python was chosen as the language of choice due to the following properties

  • Personal familiarity. Because of the tight timeframe of the project we want to ensure strong familiarity with a language and its standard library. This means Java, Python, C#, and JS/TS were considered.
  • In the specifications it can be deduced that the path of one robot can have an effect on subsequent robot if it is "lost" (goes out of bounds). This tells me that parllelism (something other languages might be stronger with due to the lack of the global interpreter lock) is not a priority.
  • The project can be modeled in a small number of classes, with most of the code base being in the application logic rather than the class structure.
  • There is file IO, and the opportunity for a small CLI. Both of these are easily achievable in Python whereas the overhead for such things in some other languages considered (Java, C#, JS) are more complex.
  • We can provide a simple web interface by deploying this as a lambda URL. This is not a priority but a nice quality of life feature that is easily achievable with Python. In an actual client scenario this enables non-technical users easy access without a lot of effort or maintainence.

rb-martian-robots's People

Contributors

ameerkat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.