Two robots solution

created by jliszka
(idea) by jliszka (2.3 y) (print)   (I like it!) Wed Apr 04 2001 at 17:26:29
This is a solution to problem 18 on the hard interview questions node. If you have not read the question, the following will make no sense to you:

Here's some code that will do the trick:

while(!at_other_robots_start) {
  move_right 1
}
while(true) {
  move_right 2
}
The idea is that both robots start moving right, and eventually the one on the left will be at the other robot's start, at which point it starts moving twice as fast to catch up to the other robot, which will obviously never hit the first robot's start.
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.