Q: So if light takes the path through a medium that takes the shortest time.. uh how does it know what path takes the least time?
A: maybe trial and error, because at that kind of time scale it can do everything at the same time and just only admit to the right thing