The Ant Problem | Microsoft , Adobe Interview

There are 100 ants on a board that is 1 meter long, each facing either left or right and walking at a pace of 1 meter per minute.

  • Adidas Stan Smith Uomo
  • The board is so narrow that the ants cannot pass each other; when two ants walk into each other, they each instantly turn around and continue walking in the opposite direction. Marcus Mariota Oregon Football Jerseys When an ant reaches the end of the board, it falls off the edge. Canotte Orlando Magic From the moment the ants start walking, what is the longest amount of time that could pass before all the ants have fallen off the plank? You can assume that each ant has infinitely small length. Goedkoop Nike Air Max         Solution :

    The longest amount of time that could pass would be 1 minute.  nike air max 2015 czarne If you were looking at the board from the side and could only see the silhouettes of the board and the ants, then when two ants walked into each other and turned around, it would look to you as if the ants had walked right by each other.  

  • New Balance 574 Donna
  • In fact, the effect of two ants walking into each other and then turning around is essentially the same as two ants walking past one another: we just have two ants at that point walking in opposite directions.

  • NIKE KOBE 11
  • So we can treat the board as if the ants are walking past each other. air max 1 pas cher In this case, the longest any ant can be on the board is 1 minute (since the board is 1 meter long and the ants walk at 1 meter per minute).

    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 |

    *