Counting Trees
Fiddler Counting Trees
Clearly, I can see the 8 trees immediately close to me. So the the number of trees I can see must be at least 8. Also, notice that the grid of trees can be divided into 8 symmetric sets.
So if I can figure out how many trees I can see in section 1 apart from the trees closest to me, I can simply multiply that count by 8 and add 8 (for my immediate trees) to the final score and that gives me how many trees I can see.
Counting how many trees I can see in section 1 beyond the
immediate trees boils down to asking the following question
Given two trees located at (a,b) and (c, d), can I see see through the gap in between the trees (I am positioned at the origin).
Can I See Through Trees?
Consider the figure below.
Given a node, we ask fraction of light gets blocked by it. We will measure fractions in angles. Since we only work in section one, it is fine to look at angles between \(\pi/4, 0\).
Given a node at location \((a,b)\), denote \(\theta_1\) and \(\theta_2\) be as shown below and let \(r\) be the radius of the tree. Let \(R = \sqrt{a^2 + b^2}\) be the distance of the tree for the origin and \(\alpha=\sin^{-1}(r/R)\). Then we have
\[\begin{align} \theta_1 &= \tan^{-1}(b/a) - \alpha \end{align}\]
\[\begin{align} \theta_2 &= \tan^{-1}(b/a) + \alpha \end{align}\]
The fraction of light this tree blocks is simply \(\theta_2 - \theta_1\).
So now we start at position \((0,0)\) and ask how much light is blocked by the nodes \((1,1)\) and \((1,0)\). Using the formula above, we get that only rays in between 34.8 degrees and 14.4 degrees pass through (see figure below)
Now we ask does light go through between \((2,1)\) and \((2, 0)\). For light to flow below \((2,1)\) we see that the acceptable anble is roughly 20.14 degrees, which is greater than 14.4 degrees from the step above. So we can conclude that light does indeed pass in between \((2,1)\) and \((2,0)\)
We repeat the process: What about \((3,1)\) and \((3,0)\)? Now we see that for light to sneak in under \((3,1)\) we need an angle of 13 ish degrees which is smaller than 14.4 so light cannot sneak in under \((3,1)\). What about \((2,1)\) and \((3, 1)\): For this to happen, light has to sneak in over \((3,1)\), and for that we need an angle of \(22.9\) degrees. But only light at a degree of at most \(20.14\) degrees light passed through the under \((2,1)\), so we conclude light does not pass between \((2,1)\) and \((3, 1)\).
We have found a perimeter to the right, now we need to find how far light reaches to the top.
We ask if light reaches in between \((1, 1)\) and \((2, 1)\), and the answer is yes. Light rays between \(34\) and \(32\) degrees pass through. What about \((2,2)\) and \((3,2)\). For this to happen, light has to go under \((2,2)\) which needs an angle of about 39 degree which is not possible or light has to go over \((3,2)\) which needs an angle of at least \(37.66\) degrees, which is not possible.
So the trees we can see in Section 1 that are not immediate neighbours are \((2,1)\), \((3,2)\) and \((3,1)\).
Thus the total number of trees is \(8*3 + 8=32\)