An interview question that caught me completely off guard.
Q. Consider a infinite square field in which you are standing at origin of the coordinate system. The field is populated with some trees that you are allergic to, such that the trees are point sized and are placed on integer coordinates tree(x,y) where x,y ∈ set of I. You have to escape from the field in straight line without touching any tree.
Ans: In an initial look at the problem it seems completely impossible to escape the field as it is an infinitely large field and the gut feeling says any line should extended indefinitely will go and touch some tree (bias from real world), also if there is any such line they should be very few. But like it is always said to gather some data.
First lets consider the cases when the line from origin touches(goes through) the tree. Coordinates of any tree T are X,Y . The equation of a line is of the form y=mx+c where m is the gradient of the line.
m =(Y-0)/(X-0) i.e m =Y/X
but we know that Y and X ∈ I , AHA we solved it you see the gradient is ratio of integers that are also coprime ( you cannot reach any x,y that are not coprime as you will stop at the first tree that you encounter on that line)to each other which satisfies the condition of a rational numbers. So we simply set the gradient of our line from origin to be an irrational no as it will never pass though any integer coordinates.
So it turns out the lines that allow escape are infinitely more than those keep us trapped in the field