diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-12-01 12:02:17 +0100 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-12-01 12:02:17 +0100 |
commit | ec5353f4018c7e1ad56d521e38ec06af8d938d97 (patch) | |
tree | 27a3df1ef495ae9070d54bd7433b5c816a06c28f /2020/1.hs | |
parent | 1fb24f91c66fb320721760a2f8fa92f1e873b4c4 (diff) |
Start of 2020
Diffstat (limited to '2020/1.hs')
-rw-r--r-- | 2020/1.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/2020/1.hs b/2020/1.hs new file mode 100644 index 0000000..c7e9d02 --- /dev/null +++ b/2020/1.hs @@ -0,0 +1,19 @@ +module Main where + +import Data.List (find) +import Data.Maybe (fromJust) +import qualified Data.Set as Set + +import Input + + +main :: IO () +main = do + input <- map read <$> getInput 1 :: IO [Int] + + let num1 = fromJust (find ((`Set.member` Set.fromList input) . (2020 -)) input) + print (num1 * (2020 - num1)) + + let pair = snd (fromJust (find ((`Set.member` Set.fromList input) . (2020 -) . fst) + [(a + b, (a, b)) | a <- input, b <- input])) + print (fst pair * snd pair * (2020 - fst pair - snd pair)) |