Coder Social home page Coder Social logo

lawn-mower's Introduction

Lawn Mower

build an automatic lawn mower designed to mow rectangular surfaces. (The mower can be programmed to mow the entire surface.) The position of the mower can be represented by coordinates (x,y) and by a letter giving the cardinal direction (N,E,W,S). The lawn is divided into a grid to simplify the navigation. For example, a mower position can be « 0, 0, N », it means that this mower is located at the lower-left corner of the lawn, and it is oriented North. The mower is controlled by sending it a sequence of letters. Possible letters are « R », « L » and « F ». « R » and « L » make the mower rotate of 90° respectively to the left or to the right, without moving. « F » means that the mower is moving forward on the cell in front of it, without changing its orientation. If the position after the move is outside the lawn, then the mower do not move, it keeps its orientation and process the next command. The cell directly at North of the position (x, y) has for coordinates (x, y+1).

Input:

An input file following these rules is given to program the mower:

  • The first line is the coordinates of the upper-right corner of the lawn, coordinates of lower-left corner are supposed to be (0,0)
  • Next lines of the file drive all mowers. There are two lines for each mower:
  • First line give the initial position and orientation of the mower. Position and orientation are given by 2 numbers and a letter, separated by a space
  • Second line is a sequence of instruction driving the mower across the lawn. Instructions are a sequence of letters without space. Each mower moves sequentially, it means that the second mower moves only after the first one execute all its instructions.

Output:

When the mower has executed all its instructions, it outputs its position and orientation.

GOAL:

Design and write a program implementing the above specifications and validating the following test.

TEST:

This file is given in input: 5 5 1 2 N LFLFLFLFF 3 3 E FFRFFRFRRF This output is expected (final positions of mowers): 1 3 N 5 1 E

Getting Started:

  • Run npm start to run the program
  • Run npm test to run the tests

lawn-mower's People

Contributors

dependabot[bot] avatar saifabusaleh avatar

Watchers

 avatar  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.