a robot is programmed to move forward 'F' meters and backwards again say 'B' meters in a straight line .the robt covers 1 meter in T units of time on robot path there is a ditch at a distance FD from intial oposition in forward direction as well as a ditch at a distance 'BD' from intial postion in backward direction this forward and backward movements is performed repeatedly by the robot

your task is to calculate amount of time taken before the robot falls either ditch if at all it falls in a ditch

This is not actually a programming question (or rather, to solve this by simulating the behaviour of the robot is a bad way to solve this). This is a simple maths question. Solve it on paper first.

This is not actually a programming question (or rather, to solve this by simulating the behaviour of the robot is a bad way to solve this). This is a simple maths question. Solve it on paper first.

Actually, this is a good program to tackle by computer simulation ... as it makes you think about the many cases ... and assumptions one might make about the given initial conditions.

For example ...

  • can either ditch be reached by one forward move
    or one forward move followed by the backward move?
    If not, what constraint does this set upon all the initial givens?

  • if either ditch not reached in 'first moves' ...
    what does this imply about the meaning of (F-B) vs
    distance from inital spot to either ditch?

Edited 1 Year Ago by David W

This article has been dead for over six months. Start a new discussion instead.