Discover where car is parked when car is using adjacent parking strategy to hide in N garages

33 Views Asked by At

The car can be parked in n garages lined up in a row. Each night the car is parked in some garage, and each day it is reparked to garages adjacent to the garage where the car was parked the previous night. For example, if one night the car was parked in garage #5, the next night it will be parked either in garage #4 or garage #6.

Assuming that we can only check one garage each night, is there a strategy that will allow us to open the garage where the car is? If so, how many days will it take to find the car?