Giter Site home page Giter Site logo

mower's Introduction

Lawn mowers technical test

The code runs with Python >= 3.6. It does not have any production dependency, relying exclusively on standard library.
It is locally pip-installable, exposing a mower command line tool, complete with debug mode.
Internal libraries powering the project are fully tested (coverage = 100%).

It is an implementation of a company's technical test.
For this reason, instructions are not linked nor explicited. Anonymity is key.

Setup

  • Clone the repository:

    git clone https://github.com/quentin-auge/mower.git
    
  • Move into the directory:

    cd mower/
    
  • (Optional) Create a virtual environment and activate it:

    virtualenv -p python3 .venv
    source .venv/bin/activate
    
  • Install the application inside the virtualenv

    pip install .
    

Run the application

To aggregate the provided instructions file:

$ cat ./sample_input.txt
5 5
1 2 N
LFLFLFLFF
3 3 E
FFRFFRFRRF

$ mower ./sample_input.txt
1 3 N
5 1 E

Debug mode:

$ mower -v ./sample_input.txt
DEBUG:mower.cli: Parsed grid size: (5, 5)
DEBUG:mower.cli: Parsed mowers: ['1 2 N', '3 3 E']
DEBUG:mower.cli: Parsed moves: ['LFLFLFLFF', 'FFRFFRFRRF']
DEBUG:mower.cli:
DEBUG:mower.cli: Mower 1
DEBUG:mower.cli:   1 2 N
DEBUG:mower.cli: L 1 2 W
DEBUG:mower.cli: F 0 2 W
DEBUG:mower.cli: L 0 2 S
DEBUG:mower.cli: F 0 1 S
DEBUG:mower.cli: L 0 1 E
DEBUG:mower.cli: F 1 1 E
DEBUG:mower.cli: L 1 1 N
DEBUG:mower.cli: F 1 2 N
DEBUG:mower.cli: F 1 3 N
DEBUG:mower.cli:
DEBUG:mower.cli: Mower 2
DEBUG:mower.cli:   3 3 E
DEBUG:mower.cli: F 4 3 E
DEBUG:mower.cli: F 5 3 E
DEBUG:mower.cli: R 5 3 S
DEBUG:mower.cli: F 5 2 S
DEBUG:mower.cli: F 5 1 S
DEBUG:mower.cli: R 5 1 W
DEBUG:mower.cli: F 4 1 W
DEBUG:mower.cli: R 4 1 N
DEBUG:mower.cli: R 4 1 E
DEBUG:mower.cli: F 5 1 E
DEBUG:mower.cli:
1 3 N
5 1 E

Usage:

$ mower --help
usage: mower [-h] [--verbose] path

Move mowers on a lawn

positional arguments:
  path           instructions file for moving the mowers on the lawn

optional arguments:
  -h, --help     show this help message and exit
  --verbose, -v  debug_mode

Run the tests

Install tox and run it:

pip install tox
tox

Tox outputs the (branch) coverage at the end.

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.