From 9a503340b2996b6da4b044800dbdc930bf0466ed Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 18 Dec 2020 12:07:18 +0530 Subject: add day18 --- lib/Utils.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/Utils.hs b/lib/Utils.hs index e0f9d62..d74a7bf 100644 --- a/lib/Utils.hs +++ b/lib/Utils.hs @@ -1,11 +1,11 @@ -module Utils where +module Utils where -import Data.Char (digitToInt) import Control.Monad +import Data.Char (digitToInt) import Data.Either -import Data.List (inits, tails) -import Data.Map (Map) -import qualified Data.Map as Map +import Data.List (inits, tails) +import Data.Map (Map) +import qualified Data.Map as Map binaryToInt :: String -> Int binaryToInt = foldl (\a x -> a * 2 + digitToInt x) 0 @@ -18,7 +18,7 @@ xor a b = (not a && b) || (a && not b) right :: Either a b -> b right (Right b) = b -right _ = undefined +right _ = undefined bet k (l, u) = k >= l && k <= u bet' k (l, u) = k > l && k < u @@ -57,7 +57,7 @@ rotate (x, y) t = (nx, ny) ny = x*sin(pi*t/180) + y*cos(pi*t/180) -- [f, f.f, f.f.f, ...] -repeatF f = f : map (f .) (repeatF f) +repeatF f = f : map (f .) (repeatF f) makeGrid :: String -> (Map (Int, Int) Char, Int, Int) makeGrid s = (grid, width, height) where @@ -66,7 +66,7 @@ makeGrid s = (grid, width, height) where width = length (head rows) height = length rows --- number theory +-- number theory egcd :: Int -> Int -> (Int, Int) egcd _ 0 = (1, 0) @@ -92,3 +92,4 @@ chineseRemainder ls = modulii = map snd ls modPI = product modulii crtModulii = (modPI `div`) <$> modulii + -- cgit v1.2.3