Let V be the speed of the bus running between towns A and B.

Speed of the cyclist, v = 20 km/h

Relative speed of the bus moving in the direction of the cyclist

= V – v = (V – 20) km/h

The bus went past the cyclist every (18/60)h min i.e., (when he moves in the direction of the bus)

Distance covered by the bus = (V - 20) (18/60)km .......................(i)

Since one bus leaves after every T minutes, the distance travelled by the bus will be equal to:

V x T/60 .............................(ii)

Both equations (i) and (ii) are equal.

(V - 20) x 18/60 = VT/60.................................(iii)

Relative speed of the bus moving in the opposite direction of the cyclist = (V + 20) km/h

Time taken by the bus to go past the cyclist = 6min = (6/60)h

Substituting the value of V in equation (iv), we get

(40+20) x 6/60 = 40T/60

T= 360/40 = 9min