From 644c38de8b633dc5e03bff5216f68b2bfde4a645 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 9 Dec 2020 11:03:39 +0530 Subject: add initial solution for day09 --- lib/Utils.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') 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 , bet , (&+) , howMany + , sublists ) where import Data.Char (digitToInt) import Control.Monad import Data.Either +import Data.List (inits, tails) binaryToInt :: String -> Int @@ -34,3 +36,6 @@ bet k (l, u) = k >= l && k <= u howMany :: (a -> Bool) -> [a] -> Int howMany predicate = length . filter predicate + +sublists :: [a] -> [[a]] +sublists = concatMap inits . tails -- cgit v1.2.3