From 7078a4fb36464cccb98ee7e7269c1535dbdb4e46 Mon Sep 17 00:00:00 2001 From: shu Date: Sat, 14 Dec 2019 15:58:16 +0100 Subject: [PATCH] =?UTF-8?q?Day=2010:=20Actually=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2019/day10/day10.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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