aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils.hs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-09 05:33:39 +0000
committerAkshay <[email protected]>2020-12-09 05:33:39 +0000
commit644c38de8b633dc5e03bff5216f68b2bfde4a645 (patch)
treeac2c0056739d38bba7855c3aa988ae190a1b158c /lib/Utils.hs
parent06b14ed84c0a8ec11462f0a6f7397c3e3a52654d (diff)
add initial solution for day09
Diffstat (limited to 'lib/Utils.hs')
-rw-r--r--lib/Utils.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Utils.hs b/lib/Utils.hs
index 4319714..89b1bd3 100644
--- a/lib/Utils.hs
+++ b/lib/Utils.hs
@@ -5,11 +5,13 @@ module Utils ( binaryToInt
5 , bet 5 , bet
6 , (&+) 6 , (&+)
7 , howMany 7 , howMany
8 , sublists
8 ) where 9 ) where
9 10
10import Data.Char (digitToInt) 11import Data.Char (digitToInt)
11import Control.Monad 12import Control.Monad
12import Data.Either 13import Data.Either
14import Data.List (inits, tails)
13 15
14 16
15binaryToInt :: String -> Int 17binaryToInt :: String -> Int
@@ -34,3 +36,6 @@ bet k (l, u) = k >= l && k <= u
34 36
35howMany :: (a -> Bool) -> [a] -> Int 37howMany :: (a -> Bool) -> [a] -> Int
36howMany predicate = length . filter predicate 38howMany predicate = length . filter predicate
39
40sublists :: [a] -> [[a]]
41sublists = concatMap inits . tails