From 0c847656e9326a994ef8ad742995d8733c28a860 Mon Sep 17 00:00:00 2001
From: Zach Perrault <zach@perrault.email>
Date: Tue, 1 Dec 2020 01:55:17 -0500
Subject: [PATCH] chore: simplify day 1, part 1

---
 2020/01/part1.hs | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/2020/01/part1.hs b/2020/01/part1.hs
index 1bc7777..fdf6dc6 100755
--- a/2020/01/part1.hs
+++ b/2020/01/part1.hs
@@ -3,22 +3,14 @@
 import Data.List
 import Data.Maybe
 
-main :: IO ()
-main =
-  do
-    input <- getInput
+main = interact findSolution
 
-    let answer = uncurry (*) $ fromJust $ find isSolutionPair $ pairs input
+findSolution = show . product . findJust isSolutionPair . pairs . parseInput
 
-    putStrLn $ show answer
+parseInput = map read . lines
 
-getInput :: IO [Int]
-getInput = fmap (map read . lines) getContents
+pairs = sequence . replicate 2
 
-pairs :: [a] -> [(a, a)]
-pairs [] = []
-pairs [_] = []
-pairs (x:xs) = [(x, y) | y <- xs] ++ pairs xs
+isSolutionPair = (2020 ==) . sum
 
-isSolutionPair :: (Int, Int) -> Bool
-isSolutionPair (a, b) = a + b == 2020
+findJust f = fromJust . find f