diff --git a/2019/day10/day10.hs b/2019/day10/day10.hs index 5e986b5..5bcf861 100644 --- a/2019/day10/day10.hs +++ b/2019/day10/day10.hs @@ -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