Giter Site home page Giter Site logo

robo-cleaner's Introduction

Robotic Cleaner

Build Status

Problem Statement

Your task is to write a Java based web service that navigates an imaginary robotic cleaner through an oil spill in the sea.

Context

  • Sea area dimensions as X and Y coordinates, identifying the top right corner of the area rectangle. This area is divided up into a grid using these dimensions; an area that has dimensions X: 5 and Y: 5 has 5 columns and 5 rows, so 25 possible cleaner positions. The bottom left corner is the point of origin for our coordinate system, so the bottom left corner of the area is defined by X: 0 and Y: 0.
  • Locations of patches of oil, also defined by X and Y coordinates identifying the bottom left corner of those grid positions.
  • The initial cleaner position (X and Y coordinates like patches of oil)
  • Navigation instructions (as cardinal directions where e.g. N and E mean "go north" and "go east" respectively)
  • The tide does not impact this simulation - the patches of oil remain in the same place throughout the execution of the program.
  • The area will be rectangular, has no obstacles and all locations in the area will be clean (cleaning has no effect) except for the locations of the patches of oil presented in the program input.
  • Navigating the cleaner onto a patch of oil removes the oil so that patch is then clean for the remainder of the program run. The cleaner is always on - there is no need to enable it.
  • In the program input attempts to navigate the cleaner outside of the boundary of the defined area an appropriate error should be returned.

Goal

The goal of the service is to take the area dimensions, the locations of the oil patches, the initial location of the cleaner and the navigation instructions as input and to then output the following:

  • The final cleaner position (X, Y)
  • The number of patches of oil the robot cleaned up

Input

Program input will be received in a JSON payload with the format described here.

Example:

{
  "areaSize" : [5, 5],
  "startingPosition" : [1, 2],
  "oilPatches" : [
    [1, 0],
    [2, 2],
    [2, 3]
  ],
  "navigationInstructions" : "NNESEESWNWW"
}

Output

Service output should be returned as JSON.

Example (matching the input above):

{
  "finalPosition" : [1, 3],
  "oilPatchesCleaned" : 1
}

Where coords are the final coordinates of the cleaner and patches is the number of cleaned patches.

Deliverable

The service:

  • is a web service
  • must run on Mac OS X or Linux (x86-64)
  • must be written using Java 8 or later using Spring Boot
  • can make use of any existing open source libraries that don't directly address the problem statement (use your best judgement).

We require:

  • The full source code, including any code written which is not part of the normal program run (scripts, tests).
  • Clear instructions on how to build and run the program.
  • Please provide any deliverables and instructions using a public Github (or similar) repository rather than ZIP files, emails and so on.

Evaluation

We will especially consider:

  • Code organisation
  • Quality
  • Readability
  • Actually solving of the problem

This test is based on the following gist https://gist.github.com/alirussell/9a519e07128b7eafcb50

Solution Overview

  • The Area is being represented as a Grid of X and Y and the oil patches and clean points are marked accordingly.
  • The Robotic Cleaner is made to move on this Grid as per the navigation instructions.
  • Before each move, the resultant X and Y coordinates are checked for validity (being inside the area).
  • If the Robotic Cleaner encounters an Oil Patch upon a move, it will be cleaned from the Area. Meanwhile, we keep track of the number of Oil Patches cleaned by the Robotic Cleaner.

Building the Project

Maven is used as the build tool. Use the below command to build the project -

mvn clean install

Dockerfile is included in the project and hence to build the Docker image, just run -

mvn dockerfile:build

Running the Project

Using Maven

It's very easy with Maven here as well, just run the below command -

mvn spring-boot:run

Using Docker Compose

If you have built the Docker image already, use the Docker Compose to run the application. Here is the command to use -

docker-compose up

Running Tests

In case if you like to run the tests alone, use the below Maven command -

mvn clean test

robo-cleaner's People

Contributors

prasadus92 avatar

Stargazers

K. Aditya Anirudh avatar Roman avatar

Watchers

James Cloos 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.