## Adobe Interview Question Developer Program Engineers

- 0of 0 votes
There is an ant in a cube placed at one corner and you need to find the shortest path to the diagonally opposite corner. The ant can not fly tht is obvious.

**Country:**India

**Interview Type:**In-Person

Good answer @Barney

The thing will be like this

First ant will reach at the opposite side of the same plane with respect to the corner in which it's right now.

So then distance covered (If A is the length of one side):

X1=A*(5^(.5))/2

Then again he will move in the same way:

X2=A*(5^(.5))/2

So total distance = A*(5^(.5))

In case of cube the minimum distance is daignal of the cube but as mention in question that ant cant fly so we will first cover the daignal of the surface in which ant is placed currently then we will cover the edge that is luying to the target corner from the current position

shortest distance would be=diagonal of the surface+edge

diagonal of the surface=sqrt(2)a

edge =a

shortest distance = a(sqrt(2)+1)

Its simple . Just open the cube box . and join the two diagonally opposite corners .

- Barney on July 03, 2012 Edit | Flag ReplyI mean first ant will move to the middle of the opposite side on the same plane from the staring point .

Then from that point , it'll start move to the corner (which lies diagonally opp to the starting point )

Total length covered = a*(5^0.5)