summaryrefslogtreecommitdiff
path: root/2020/1.hs
diff options
context:
space:
mode:
Diffstat (limited to '2020/1.hs')
-rw-r--r--2020/1.hs19
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))