Latest News

Thursday, 19 April 2012

Parachutist Dilemma - a parallel programming problem

Here is a little mental problem solving exercise for you to try to do in 30 seconds; that was the time I was allowed. So I had a telephone interview from a company today and this guy asked me this question utilizing a parrallel programming algorithm. Here are the details:

Two parachutist (A and B: A is in front of B) land on single line; one behind the other. Their parachutes also lands behind them respectively. 
We have a set of instructions which are as follow (all instructions are executed, meaning A and B will executed instructions at the same time).
  1. move forward 1 step
  2. move back 1 step
  3. if standing on a parachute go to (1 | 2)

Question:

We need our parachutist to somehow meet each other, what are the sets of instructions that can make that happen?


Please try to answer before reading my answer below

My answer:

  1. execute 2
  2. execute 3
Explanation:

  • When both parachutist move back 1 step, they will both be on their parachutes
    • when parachutist A stands on his parachute, he will move back 1 step therefore go to 1
    • when parachutist B lands on his parachute, he will move forward 1 step 
Therefore our two parachutist will meet in B original position.

NB I had to change the original questions as the interviewer explanations led to the parachutist to never meet.
  • Blogger Comments
  • Facebook Comments

5 comments :

Post a Comment

Item Reviewed: Parachutist Dilemma - a parallel programming problem Description: Rating: 5 Reviewed By: Armel Nene
Scroll to Top