diff options
author | Akshay <[email protected]> | 2020-12-09 05:33:39 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-09 05:33:39 +0000 |
commit | 644c38de8b633dc5e03bff5216f68b2bfde4a645 (patch) | |
tree | ac2c0056739d38bba7855c3aa988ae190a1b158c /lib | |
parent | 06b14ed84c0a8ec11462f0a6f7397c3e3a52654d (diff) |
add initial solution for day09
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Utils.hs | 5 |
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 | ||
10 | import Data.Char (digitToInt) | 11 | import Data.Char (digitToInt) |
11 | import Control.Monad | 12 | import Control.Monad |
12 | import Data.Either | 13 | import Data.Either |
14 | import Data.List (inits, tails) | ||
13 | 15 | ||
14 | 16 | ||
15 | binaryToInt :: String -> Int | 17 | binaryToInt :: String -> Int |
@@ -34,3 +36,6 @@ bet k (l, u) = k >= l && k <= u | |||
34 | 36 | ||
35 | howMany :: (a -> Bool) -> [a] -> Int | 37 | howMany :: (a -> Bool) -> [a] -> Int |
36 | howMany predicate = length . filter predicate | 38 | howMany predicate = length . filter predicate |
39 | |||
40 | sublists :: [a] -> [[a]] | ||
41 | sublists = concatMap inits . tails | ||