Darts is an age-old game that originated among soldiers who started competitions as a pastime between battles. They threw short arrows at the bottom of wine barrels and later at discs made of the trunks of trees. Scores were added onto the discs. Out of necessity, the sport was played inside during the winter months, which forced the soldiers to replace the arrows with darts and led to a new set of rules for practicing the indoor sport. As the game continued to develop, the richer layers of population gained an interest in darts. It is written that Hendrik VIII's second wife Anne Boleyn gave him a richly decorated Biscayan darts set.
The current dartboard comes from London. The board consists of a round fiber plate of 18 millimeters thick, on which sisal fiber bristles are glued and pressed under large pressure. The whole is framed by a metal band. The board is provided with a section division using different colors. After that, a metal web is fixed on top of the plate, provided with the same division. The function of this web is to make sure that it is always clear in which section the dart landed. On the outer border, a metal ring is placed on which numbers are fixed according to the section division. This ring can be detached from the rest of the board, making it possible to shift the numbers with regards to the plate.
The idea is that the section (bed) 20 is in the middle on top. This section is usually the most favorite target. This is why the bottom plate of this section is likely to break first. Every dart that is thrown affects the fibers of the board. The glue layer prevents the board from falling apart, but after a while, an accumulation of fibers will be visible under the form of lumps. To prevent this, the board should be turned around every now and then, so that 20 is always on top of another section. Do note that 20 should always be on top of a black section. Modern sisal fiber boards shouldn't be made wet (unlike what is often thought).
The measurements of a dartboard are indicated in the picture above. The double ring and triple ring are always 9.6 mm wide.
The dartboard is divided in rings and sections. The numbers at the rim indicate the amount of points you receive for throwing a dart in that particular section. In this assignment, the sectors are numbered clockwise from 1 starting at the top section. The sections are further subdivided in a number of smaller partitions.
in the middle is the double bull or bull's eye (red), 50 points
around the double bull is the single bull (green), 25 points
around that a wide ring, the bed (black and white), for which the amount of points that is indicated on the rim of the board is granted
around that a smaller ring, the triple (or treble) ring (red and green); this yields a triple score of the bed
around that is another bed
around that is the double ring (red en green) yields a double score of the bed
If you throw a dart in the outer black rim (where the numbers are) or next to the board, you don't get any points. A bouncer — a dart that bounces back from the board — doesn't give a score neither. You also won't receive any points if one of your darts falls from the board before you were able to take your darts out (please note, officially this isn't called a bouncer). If a player throws in one of his previously thrown darts (a Robin Hood), the last dart doesn't receive a score.
We consider a Cartesian coordinate scale1 with its origin in the center of the bull's eye of a dartboard. A player throws a dart to the board that lands on coordinates $$(x, y)$$, with coordinates expressed in millimeters. Determine the score that is obtained by this dart. In order to do so, it is best to first convert the Cartesian coordinates $$(x, y)$$ of the position where the dart has landed into polar coordinates $$(r, \theta)$$, and then to determine the score of the corresponding sector based on the angle $$\theta$$.
The first step towards the solution is to convert the position $$P$$ where the dart has landed on the dartboard from the coordinates $$(x, y)$$ in the Cartesian coordinate scale into polar coordinates $$(r, \theta)$$. The tuple $$(r, \theta)$$ of real valued numbers expresses the position of the point $$P$$ in polar coordinates2, where the pole $$O$$ coincides with the center of the bull's eye, and the pole axis coincides with the $$X$$ axis. The coordinate $$r$$ of the point $$P$$ is the distance $$OP$$. The coordinate $$\theta$$ indicates the oriented angle between the positive $$X$$ axis and the half straight line of O through P. This angle is expressed in radians, and it must hold that $$-\pi < \theta \leq \pi$$.
The relationship between the Cartesian coordinates $$(x, y)$$ and the polar coordinates $$(r, \theta)$$ is given by the formulas \[\begin{cases} r = & \sqrt{x^2+y^2} \\ \\ \theta = & \arctan\left(\frac{y}{x}\right) \end{cases}\]
The image below illustrates how an angle in polar coordinates ($$\theta$$; the green angle) can be converted into an angle ($$\beta$$; the red angle) that can be used to determine the corresponding sector.
Using a little bit of trigonometry, it is easy to see that \[ \beta + \theta = \frac{\pi}{2} + \frac{\pi}{20}\,, \] or in other words, \[ \beta = \frac{\pi}{2} + \frac{\pi}{20} - \theta\,. \] Once $$\beta$$ has been computed and you know that each sector covers an angle of $$\frac{\pi}{10}$$, you can convert the angle $$\beta$$ into the index of the sector. The first sector (the one on top of the $$Y$$-axis) has index 0, the one to the right of it has index 1, and so on in a clockwise manner.
The numbers $$x, y \in \mathbb{R}$$, each on a separate line. These numbers represent the position $$(x, y)$$ of the point $$P$$ in the Cartesian coordinate scale with its origin in the center of the bull's eye of a dartboard. The units of the coordinate scale are expressed in millimeters.
The score that is awarded to a dart thrown at position $$P$$ on the dartboard.
Input:
-30.0
22.0
Output:
18