1234567891011121314151617181920212223242526272829303132333435 |
- {-# LANGUAGE QuasiQuotes #-}
- module Day4Spec (spec) where
-
- import Test.Hspec
- import Text.Heredoc
- import Day4.Part1
- import Day4.Part2
- import Day4.Shared
-
- inputPart1 :: String
- inputPart1 = [str|2-4,6-8
- |2-3,4-5
- |5-7,7-9
- |2-8,3-7
- |6-6,4-6
- |2-6,4-8
- |]
-
-
- spec :: Spec
- spec =
- describe "Day4" $ do
- describe "Part 1" $ do
- it "parses section" $ do
- section "2-4" `shouldBe` 2 +=+ 4
- it "parses section pair" $ do
- elfPair "2-4,6-8" ` shouldBe` (2 +=+ 4, 6 +=+ 8)
- it "finds fully overlapping sections" $ do
- isFullyOverlapping (3 +=+ 6, 4 +=+ 6) `shouldBe` True
- it "counts fully overlapping pairs" $ do
- countFullyOverlappingPairs inputPart1 `shouldBe` 2
- describe "Part 2" $ do
- it "counts overlapping pairs" $ do
- countOverlappingPairs inputPart1 `shouldBe` 4
|