Welcome to My Spaceship


Task

Your ship simulator must take in a string of letters that represent a planned flight path for a given rocket ship.

In a ship’s flight path there are only 3 valid options for movement; R for turning right, L for turning left and A for advancing.

If, for example, you receive “RRALAA” as your flight path, you should interpret it as the following: Turn right, turn right, advance, turn left, advance, advance Once given this initial flight path, your program must return the x,y coordinates of a ship’s final destination as well as it’s orientation relative to the starting point.

Orientation is represented as left, right, up or down

Space is infinite, so the x,y coordinates you return could be placed on a seemingly infinite grid and can be negative or positive values.

So let's say an upward-facing rocket ship leaves its starting point of 0,0 and is given the flight path of “RRALAA”, its final location will be 2,-1 and it will be facing right.

Description

You must create a function that takes in a flight path of a rocket ship as a string of letters and returns the following format: "{x: X, y: Y, direction: 'DIRECTION'}" X,Y represent the ending coordinates of your ship and direction represents its final direction.

Installation

N/A

Usage

Call the function and enter a string as the parameter to see the coordinates and direction

The Core Team

Made at Qwasar SV -- Software Engineering School <img alt='Qwasar SV -- Software Engineering School's Logo' src='https://storage.googleapis.com/qwasar-public/qwasar-logo_50x50.png' width='20px'>