Day 10: Actually …

This commit is contained in:
shu 2019-12-14 15:58:16 +01:00
parent b2542fa250
commit 7078a4fb36

View File

@ -8,15 +8,13 @@ data Asteroid =
deriving (Show)
instance Eq Asteroid where
Asteroid a b == Asteroid c d = phi' a b == phi' c d
Asteroid a b == Asteroid c d = phi a b == phi c d
instance Ord Asteroid where
Asteroid a b `compare` Asteroid c d = phi a b `compare` phi c d
where
phi x y = phi' (fromIntegral x) (fromIntegral y)
phi' :: Int -> Int -> Double
phi' xi yi
phi :: Int -> Int -> Double
phi xi yi
| x >= 0 = atan2 x (-y)
| otherwise = 2 * pi + atan2 (-x) y
where x = fromIntegral xi