Coder Social home page Coder Social logo

multiverse-mars-rover's Introduction

Multiverse Mars Rover

An implementation of Mars Rover Challenge using:

  • Bun - New & faster JS runtime environment (faster than V8)
  • Typescript - JavaScript with syntax for types
  • Jest - Testing framework

Challenge

Write a program that takes in commands and moves one or more robots around Mars.

Note: I've tweaked this challenge to support multiple planets (Mercury, Venus, Earth, etc...)

  • The world should be modelled as a grid with size (m x n)
  • The program should read the input, update the robots, and print out the final states of the robots
  • Each robot has a position (x, y), and an orientation (N, E, S, W)
  • Each robot can move forward one space (F), rotate left by 90 degrees (L), or rotate right by 90 degrees (R)
  • If a robot moves off the grid, it is marked as ‘lost’ and its last valid grid position and orientation is recorded
  • Going from x -> x + 1 is in the easterly direction, and y -> y + 1 is in the northerly direction. i.e. (0, 0) represents the south-west corner of the grid

Questions

  • Can robots encounter obstacles? i.e. other robots? I'm assuming we don't as part of this challenge
  • What happens if a robot receives a command that is not supported?
  • What happens if a robot hasn't landed? (i.e. initial coordinates of robot is not valid)
  • What happens if the robot is a complete bimbo? (i.e the orientation isn't valid)
  • Do we have any limitations? i.e. program should run in O(n)? I don't think thats possible since each robot can have m number of commands? Maybe O(nm)?
  • Can grid coordinates have negative values? - For the sake of this challenge, I have excluded this use-case
  • Why doesn't the robot support backwards? - I've added this functionality

Getting Started

To run the program, you need to have Bun installed. See their doc.

Run


┌─[ multiverse-mars-rover ] on  master via ⬢ v19.1.0
└─▪ git clone [email protected]:bitabs/multiverse-mars-rover.git

┌─[ multiverse-mars-rover ] on  master via ⬢ v19.1.0
└─▪ cd multiverse-mars-rover

┌─[ multiverse-mars-rover ] on  master via ⬢ v19.1.0
└─▪ bun install # faster than npm

┌─[ multiverse-mars-rover ] on  master via ⬢ v19.1.0
└─▪ bun start # Runs the program

Test


┌─[ multiverse-mars-rover ] on  master via ⬢ v19.1.0
└─▪ bun test # Runs the tests

multiverse-mars-rover's People

Contributors

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