Robots on a line | Microsoft interview

Two robots are placed at different points on a straight line of infinite length. Air Jordan 14 Uomo When they are first placed down, Women Air Jordan 14 they each spray out some oil to mark their starting points.

  • Air Max 2017 Donna
  • You must program each robot to ensure that the robots will eventually crash into each other. nike tn pas cher 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. Authentic Air Jordan Shoes For example, you could label the third line of your program “surveying”. Punahou High School(Honolulu) Then, Goedkope Nike Air Max 90 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. New Balance 997 hombre Both robots need not have the same program.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    For Inserting code :
    Paste your code in the comment form, select it and then click the language link

    C | C++ | Java |

    *