aboutsummaryrefslogtreecommitdiff
path: root/execs/Day05.hs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-05 07:49:25 +0000
committerAkshay <[email protected]>2020-12-05 07:49:25 +0000
commit555da2ae6f658672cfc0d37e437ec356c0c0fa63 (patch)
treef1b1b2e411ac130373421aece0cb8e5709a0e925 /execs/Day05.hs
parente0a5d9cbf99c2d6bbaef12f2ce5506eda0ba5bec (diff)
factor common functions into Utils
Diffstat (limited to 'execs/Day05.hs')
-rw-r--r--execs/Day05.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/execs/Day05.hs b/execs/Day05.hs
index aae8f49..27397f7 100644
--- a/execs/Day05.hs
+++ b/execs/Day05.hs
@@ -1,12 +1,11 @@
1module Main where 1module Main where
2 2
3import Data.Char (digitToInt) 3import Data.Char (digitToInt)
4import Utils (binaryToInt)
4 5
5doValidate = toInt . map readBin 6doValidate = binaryToInt . map readBin
6toInt = foldl (\a x -> a * 2 + digitToInt x) 0 7readBin s | s `elem` "FL" = '0'
7readBin 'F' = '0' 8 | otherwise = '1'
8readBin 'L' = '0'
9readBin _ = '1'
10 9
11main :: IO () 10main :: IO ()
12main = do 11main = do