hmm the exact solution is quite fantastic for anyone who is interested in calculus.
first assumption. light takes the fastest path. this is a proof in quantum electrodynamics by feynmann.. so its too high right now. just assume it is true.
now take this case.
there are 2 slabs of materials
1 and
2 . their lengths are anything.. suppose they are both d.(it doesnt matter.. it cancels)
now suppose light fall on the interface from one of the sides at some angle
1 and goes into the other at
2 .(refraction occurs due to some other reason which is not importanr here).
now form equations which make the TIME to reach the other side least. so the light travels in medium 1 and 2 for different amounts of time. the speeds in the 2 media can be found with the refractive indices.(use speed of light etc)
say it takes T1 secs in first medium and T2 secs in second.
differentiate w r t the unknown and = 0.
you will get snell's law.