Robots on a line puzle
Two robots are placed at different points on a straight line of infinite length. When they are first placed down, they each spray out some oil to mark their starting points.
You must program each robot to ensure that the robots will eventually crash into each other. A program can consist of the following four instructions:
- Go left one space
- Go right one space
- Skip the next instruction if there is oil in my current spot
- Go to a label
[Note that a “label” is a name that refers to a line of your code. For example, you could label the third line of your program “surveying”. Then, the instruction “goto surveying” would jump to line 3 and start executing from there on the next cycle.]
A robot will carry out one instruction per second. Both robots need not have the same program. Note that you won’t know ahead of time which robot is on the left and which is on the right.
Algorithm-
[Label: move_slowly]
1 Move Right
2 Move Right
3 Move Left
4 Skip Next Instruction If On Oil
5 GOTO move_slowly
[Label: move_quickly]
6 Move Right
7 GOTO move_quickly
The Question is not clear enough: Once the robot turned right one step and gets another order “go right one step” he does not keep straight but turns right from the last point!! I tried to draw the solution and I found that I got a shape of cross where I go back to where I started so now if the robot is facing the oil he goes to the instruction move right again and again so he move in a circle starting from the oil point. This is also that case of the 2nd robot. So how do they meet?
let the blue line bee the infinite line between north and south and the robot facing north at point A. So by going right, right, left, then after four times we get back to where we started , and now going only right moves us in circle!!
Your Answer
More puzzles to try-
Helper all the time
You use it everyday but let it rest at night. It has an identical twin beside it all the time. ...Read More »People in Bus
You are on a bus. 10 people get on at the first stop. At the next stop 25 people get ...Read More »Story of Friends
Out of three Friends John, Jacob and Jonny one of them is a king, one is a bureaucrat, and one ...Read More »In which year was the grandfather born?
Recently, somebody told: “My grandfather was born on the first sunday of the year. His seventh birthday was also on ...Read More »Which animal in the room is the smartest?
You walk into a room with a rabbit holding a carrot, a pig eating slop, and a chimp holding a ...Read More »Coin and Glass interview question
A guy claims to do the following thing. He puts a coin in a glass bottle. Then, he shuts the ...Read More »Fins and Feathers
Hostile members of the Uti, Grundi and Yomi groups were travelling to a conference. There were two members from each ...Read More »Moms and Daughters
There are two moms and two daughters. One mom is the daughters mom. The other mom is the mom’s mom. ...Read More »How many vegetables can grow off of the vine?
A tomato vine is 3 meters long. The bottom foot of the vine doesn’t grow any tomatoes but the rest ...Read More »Six kings and birbal intelligence puzzle
Once upon a time, Emperor Akbar was the ruler of India. In his court, he had the much talked about ...Read More »Hot Handle riddle
What is represented by this BrainBat? HOT HOT HANDLE HANDLERead More »Complete the equation
Below, you can see three complete equations and one incomplete. Based on the three complete ones, can you complete the ...Read More »Mixing vinegar and oil
You have two jars. One contains vinegar, the other oil. The two jars contain the same amount of their respective ...Read More »In you and around you
It is essential to life, yet it can take your breath away. It is both in you and around you. ...Read More »Bulb and switch riddle
You are in a room with three light switches, each of which controls one of three light bulbs in the ...Read More »Seam Beam and dream puzzle
If all Seams are Beams and all Beams are Dreams, can all Dreams be Seams?Read More »Disney land Racing Puzzle
Doremon organized a race in which Schinchen, jerry, Oggy, and Nobita have participated. The results of the race is as ...Read More »Short or Tall
It is something or nothing. It is short or tall. When you fall at your sport, then it stumble and ...Read More »Five Wheels think Four
It has five wheels, though often think four, You cannot use it without that one more, You can put things ...Read More »Driver date of birth puzzle
You are driving a car from New York to Washington DC. Car no is DZ-2817. The distance is 226.0 miles. ...Read More »