Done day 20
[advent-of-code-16.git] / advent20.hs
index aab974a15247afa21877c825d500096be36995d0..8935f8656dd8b2ed5b4b1e492e353e27ccba38a7 100644 (file)
@@ -19,7 +19,7 @@ main = do
     text <- readFile "advent20.txt" 
     let intervals = successfulParse $ parseIfile text
     part1 intervals
-    -- part2
+    part2 intervals
 
 part1 :: [Interval] -> IO ()
 part1 intervals = print $ (+1) $ high $ head $ foldl' (mergeAdjacent) [] $ foldl' (merge) [] intervals
@@ -28,8 +28,8 @@ part2 :: [Interval] -> IO ()
 part2 intervals = do
     let ints = foldl' (mergeAdjacent) [] $ foldl' (merge) [] intervals
     let gapCount = gaps ints
-    let lowGap = max [0, ((low $ head ints) -1)]
-    let highGap = 4294967295 - (min [4294967295, ((high $ last ints) + 1)])
+    let lowGap = low $ head ints
+    let highGap = 4294967295 - (high $ last ints)
     print (lowGap + gapCount + highGap)
 
 -- 4294967295