0% found this document useful (0 votes)
59 views2 pages

Coding Challenge: Online IDE

The document describes a coding challenge where two robots, Robo1 and Robo2, navigate a 6x6 grid to collect treasures. The player with the most treasures wins. Robot positions and instructions are given as input, and the output should state each robot's final position and treasure count, indicating the winner or a tie.

Uploaded by

Ritu Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

Coding Challenge: Online IDE

The document describes a coding challenge where two robots, Robo1 and Robo2, navigate a 6x6 grid to collect treasures. The player with the most treasures wins. Robot positions and instructions are given as input, and the output should state each robot's final position and treasure count, indicating the winner or a tie.

Uploaded by

Ritu Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Online IDE – Use any Online IDE of your choice e.g. https://repl.it or https://vscode.

dev/ or
any other.

Coding Challenge
The Robo Treasure Hunt
Company Rubix has a 6X6 Robot play arena with treasures hidden at certain locations (think
of it as a 6X6 grid). There are 2 players - Robo1 and Robo2.

Each player can command and control their robots. There are treasures laid out on different
points in the arena and the robot needs to collect treasures on the route we define.

Your coding challenge is to display the player who has more treasures.

A robot's position and location is represented by a combination of x and y coordinates and a


letter representing one of the four cardinal compass points which indicates the direction the
Robot is facing.

For example 2 3 N means the Robot is at 2 on the x coordinate, 3 on the y coordinate, and
facing North.

You can control the robot by sending 'L', 'R' and 'M'. 'L' and 'R' makes the robot turn 90
degrees left or right respectively, without moving from its current spot. 'M' means moving
forward one grid point in the direction it is facing.

Instruction L on 1 2 N will result in 1 2 W


Instruction R on 1 2 N will result in 1 2 E
Instruction M on 1 2 N will result in 1 3 N

Every input line will have 3 entries.

The 1st line of input has comma separated coordinates of the treasure locations.
Eg: if the input is 1 3, 3 3 it means treasures are available at grid locations 1 3 and 3 3.

The next 2 lines of input is the information pertaining to the robots that have been deployed.
Each of these lines gives the robot's position, and a series of instructions telling the robot
how to navigate the grid.

Eg: Robo1 0 2 E MMMLM


Robo2 5 0 N MMMMM

The output should print the name of the players, and their final position, with their treasure
count. Also indicate who won the treasure hunt.
Sample Input1 -
1 1, 3 3, 5 5
Robo1 0 2 E MMMLM
Robo2 5 0 N MMMMM

Output
Robo1 3 3 N 1
Robo2 5 5 N 1
TIE
Sample Input2 -
4 5, 2 3, 4 1, 4 4, 5 2
Robo1 1 2 N MRMMLMMMRMRMM
Robo2 2 0 S LMMLMMRMLMMMML
Output
Robo1 4 3 S 3
Robo2 5 5 W 2
Robo1 WINS

Upload code here when done -> https://codu.ai/upload/Rubix. Do mention your full name
and correct email id when you submit. Choose Robo Hunt as the coding problem.

Assumptions:
• If the Robot reaches the boundary and if he will fall off the grid on the next
instruction, then skip that instruction and move on to next. Each treasure location has
an unlimited amount of treasures. At a time a Robot can pick only one treasure from
one spot. A tie is a possible outcome.
• If 2 robots are in the same grid, both of them get a treasure.

6 x 6 matrix
5, 0 5, 1 5, 2 5, 3 5, 4 5, 5

4, 0 4, 1 4, 2 4, 3 4, 4 4, 5

3, 0 3, 1 3, 2 3, 3 3, 4 3, 5

2, 0 2, 1 2, 2 2, 3 2, 4 2, 5

1, 0 1, 1 1, 2 1, 3 1, 4 1, 5

0, 0 0, 1 0, 2 0, 3 0, 4 0, 5

You might also like