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).
- move forward 1 step
- move back 1 step
- 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:
- execute 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.