The difficulty with sharing pizza with friends is that it is hard to make sure that everyone gets the same amount of pepperoni on their slice. So, your task is to decide how to fairly slice a pizza so that everyone is happy.
Write a program that, given a list of the positions of pepperonis on a circular pizza and the number of slices to be made, outputs a list of the angles that the pizza should be cut at so that each slice has the same amount of pepperoni on it.
- The pizza has only one topping: pepperoni.
- Your friends don't care about the size of their slice, just that they are not cheated out of any pepperoni.
- The pizza is a circle centered on the origin
(0, 0)and with a radius of
- The pepperonis are circles that are centered wherever the input says they are centered and have a radius of
- Take input as an integer that represents the number of slices to be made and a list of ordered-pairs that represent the positions of the pepperonis on a cartesian coordinate system. (In any reasonable format)
- Output should be a list of angles given in radians that represents the positions of the "cuts" to the pizza (in the range
0 <= a < 2pi). (In any reasonable format) (Precision should be to at least
- You can have partial pieces of a pepperoni on a slice (eg. If a pizza has one pepperoni on it and it needs to be shared by 10 people, cut the pizza ten times, all cuts slicing through the pepperoni. But make sure it's fair!)
- A cut can (may have to) slice through multiple pepperonis.
- Pepperonis may overlap.
8 people, pepperonis: (0.4, 0.2), (-0.3, 0.1), (-0.022, -0.5), (0.3, -0.32)
Possible valid output:
slices at: 0, 0.46365, 0.68916, 2.81984, 3.14159, 4.66842, 4.86957, 5.46554
Here is a visualisation of this example (everyone gets half a pepperoni):
Input: 9 people, 1 pepperoni at: (0.03, 0.01) Output: 0, 0.4065, 0.8222, 1.29988, 1.94749, 3.03869, 4.42503, 5.28428, 5.83985
Input: 5, (0.4, 0.3), (0.45, 0.43), (-0.5, -0.04) Output: 0, 0.64751, 0.73928, 0.84206, 3.18997
This is code-golf, so least number of bytes wins.