Can anyone help me to solve this problem

I’ve given a problem and I’ve to write a program in any language. I can’t seem to get my head around it. Can anyone solve this problem for me.

Problem:

A robotics company wants to do something special for it’s 50 year anniversary. The CEO decides that they should turn their glass building into a colorful mosaic using some of their own robots. So, a group of smart engineers come up with a design for robots that can climb the glass building and install color filters on the glass panels.

The glass building can be considered a rectangular grid with each glass panel representing a cell. A robot’s location is represented by x and y coordinates. It’s heading is represented by one of four cardinal compass points. An example position could be <0, 0, N>, which means that the robot is at the bottom-left corner and facing up.

Two robots are built, each capable of installing a specific color filter, namely red ® and green (G). The color filters are additive i.e. combining R and G produces yellow (Y).

Each robot is capable of understanding the following commands:

  • L – turn left 90 degrees

  • R – turn right 90 degrees

  • F – move forward 1 cell

  • I – install color filter on the current cell

Input:

Simple command strings are written by the engineers to get the robots to color the building.

The first line of input represents the size of the building with the base index being <0, 0>.

The rest of the input is data pertaining to the robots. Each robot has two lines of input. The first line gives the robot’s position and color, and the second line is the sequence of commands that tell the robot where to navigate.

Each robot will finish its navigation sequentially, which means that the second robot wont start moving until the first one has finished moving.

Output:

The output should be a grid of characters denoting the state of the building after all robots have completed their tasks.

E = empty

R = red

G = green

Y = yellow

Sample Input and Output:

Input:

5 5

0 0 N R

FFRFIFIRFIF

4 0 N G

FLFFRFIRFILFLFI

Expected output:

EEEEE

EEGEE

ERYGE

EEREE

EEEEE

can anyone solve this problem for you???

@kunnu120 Sorry! I came here seeking help. Please spare me :slight_smile:

no @pavan_28 I’m sorry I meant that do you need help with your question or you want someone to write your code? Anyway, I can’t help you with your problem because I’m a noob programmer and I really don’t know the stuff you need help with. But I’m sure @vijju123 can show you a right way, although I don’t think so anyone can write the whole program for you

@kunnu120 Ah ok :slight_smile: appreciated the help!

@pavan_28 not a problem!! :slight_smile:

Its actually a simple brute force algorithm. If you want hints, you can go through this problem and the editorial-

Also, please try to give problem link instead of copy-pasting the statement, we need to verify that its not related to an on going contest.

Sorry, I’ve given this problem in an interview. So I came here to seek help.

Ok. Of you find any trouble understanding, ping me back. The heart of problem is, starting from co ordinate of robot, following the orders via index changing in 2-D table, and finally print the updated table. Its pure brute force.

Can you give me your email id, I want to reach you personally.

Search for it :stuck_out_tongue:

1 Like

Got it Thanks :slight_smile: