diff options
author | Akshay <[email protected]> | 2020-12-05 07:49:25 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-05 07:49:25 +0000 |
commit | 555da2ae6f658672cfc0d37e437ec356c0c0fa63 (patch) | |
tree | f1b1b2e411ac130373421aece0cb8e5709a0e925 /execs/Day05.hs | |
parent | e0a5d9cbf99c2d6bbaef12f2ce5506eda0ba5bec (diff) |
factor common functions into Utils
Diffstat (limited to 'execs/Day05.hs')
-rw-r--r-- | execs/Day05.hs | 9 |
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 @@ | |||
1 | module Main where | 1 | module Main where |
2 | 2 | ||
3 | import Data.Char (digitToInt) | 3 | import Data.Char (digitToInt) |
4 | import Utils (binaryToInt) | ||
4 | 5 | ||
5 | doValidate = toInt . map readBin | 6 | doValidate = binaryToInt . map readBin |
6 | toInt = foldl (\a x -> a * 2 + digitToInt x) 0 | 7 | readBin s | s `elem` "FL" = '0' |
7 | readBin 'F' = '0' | 8 | | otherwise = '1' |
8 | readBin 'L' = '0' | ||
9 | readBin _ = '1' | ||
10 | 9 | ||
11 | main :: IO () | 10 | main :: IO () |
12 | main = do | 11 | main = do |