https://github.com/pedroka-dev/martian-robot
🛰 C# .NET console app that moves and rotates a "robot" on a custom grid based on a string input of commands.
https://github.com/pedroka-dev/martian-robot
coding-exercise csharp
Last synced: 5 months ago
JSON representation
🛰 C# .NET console app that moves and rotates a "robot" on a custom grid based on a string input of commands.
- Host: GitHub
- URL: https://github.com/pedroka-dev/martian-robot
- Owner: pedroka-dev
- License: mit
- Created: 2021-04-11T19:11:59.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-13T20:37:53.000Z (almost 2 years ago)
- Last Synced: 2025-01-26T11:44:35.537Z (about 1 year ago)
- Topics: coding-exercise, csharp
- Language: C#
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Martian Robot
A robot that moves and rotates based on a string input
# About the System
The chosen area for analysis is curiously rectangular, and the robots must walk through it with their cameras on, collecting all kinds of information. A robot's position is represented by a combination of X and Y coordinates and also a letter representing the direction it is facing. The area is divided into a grid to simplify navigation. An example of a position could be: 0,0,N, meaning the robot is in the bottom left part facing north. Use the following orientations: N = north, S = south, L = east, O = west. To control the robot, AEB sends simple strings with commands. Possible letters are: E, D, and M. The letters E and D make the robot turn 90 degrees to the left and right, respectively, without moving from its place. The letter M means moving one position forward on the grid, maintaining the same direction. Assume that moving the robot forward means moving its position from (X, Y) to (X, Y+1). For example, a robot at position (0,0) facing north, when moving one position, will end up at (0,1).
# Input
The program should have the following parameters: – The first line should be the coordinates of the upper right corner of the area. The lower left corner is always (0,0). – The rest of the inputs should be the commands the robot must execute. Each command should be sent in 2 parts: the first part is the initial position of the robot, and the second is a series of instructions that the robot must follow to explore the area. The position is given with 2 integers and a letter, separated by spaces, corresponding to the X and Y coordinates and the robot's orientation. Each robot will execute the instructions sequentially: the second robot will only start its actions when the first one finishes.
# Output
For each robot, the final position and its orientation after executing the instructions.
# Examples
Input:
5 5
1 2 N
EMEMEMEMM
3 3 L
MMDMMDMDDM
Expected Output:
1 3 N
5 1 L