Curling is a sport where two teams aim to place stones as close to the centre of a target as possible. The winner of a curling end is the team whose stone is closest to the centre – they score as many points as the number of their stones closer to the centre than any of their opponents.
Task
Given two lists of pairs of integers representing the Cartesian coordinates of both teams' stones, with the origin as target centre, output a positive integer if one team wins and a negative integer if the other wins; the sign must be consistent with input order. The magnitude of this integer is the number of points scored.
Ties are broken as follows:
- If there are no stones at all or there is a tie between teams for the closest stone, no points are scored and 0 should be returned.
- If there is a winning team, any of their stones at exactly the same distance as their opponent's closest stone do not count for points.
Input formatting is flexible – you may use a complex number to represent a stone's coordinates or tag the coordinates with their corresponding teams, for example. The distance of (x,y) from the origin is \$\sqrt{x^2+y^2}\$ – scaling is equal in both directions.
This is code-golf; fewest bytes wins.
Test cases
These assume the team whose stones' coordinates are listed first is associated with a positive output.
[],[] -> 0
[(1,0)],[] -> 1
[],[(0,1)] -> -1
[(2,0),(2,1),(2,2),(2,-1),(2,-2),(-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2)],[(0,1),(0,-1)] -> -2
[(4,3),(3,3),(-3,-3),(-1,0)],[(4,1)] -> 1
[(-3,2)],[(2,2),(0,-8),(-1,-1),(3,6)] -> -2
[(0,0),(1,0),(0,1)],[(1,1),(1,-1),(-1,1),(-1,-1)] -> 3
[(-7,1)],[(5,5)] -> 0
[(1,0),(2,0)],[(-2,0)] -> 1
[(-3,-4),(0,5)],[(-1,2),(4,3),(4,-3),(-3,0)] -> -2
Obviously this question was inspired by the curling events at the 2022 Winter Olympics.