MOG Training #7Ended |
After being stationed on Hoth, you’ve decided that this is the worst decision you have ever made. The planet is cold, there is nothing to do, and to make matters worse, the Empire keeps sending probe droids down to see if anyone is hiding on the planet. At least you can do something about the probe droids!
The field near your base is covered with these droids in a uniform fashion. Your base has a turret in the southwest (bottom-left) corner of the field, at location $(1, 1)$. Each remaining lattice point (points with integer coordinates) on the grid of $n \times m$ points contains a droid.
An example $3 \times 5$ grid:
Note that row $1$ is at the bottom, row $n$ is at the top, column $1$ on the left and column m on the right.
Your base is at coordinate $(1, 1)$, while the droids are at all positive coordinates in the range $(1..n,1..m)$, excluding $(1, 1)$ of course. Your base has a turret on it facing east, towards highernumber columns in row $1$. You’ve programmed the turret to operate in the following way: If a droid is its line of sight, then destroy the droid. Otherwise, rotate counter-clockwise until the turret can see a droid. Keep going until all droids are destroyed.
Your task is to figure out the $i^{th}$ droid destroyed when the turret executes your algorithm.