Day 4
This commit is contained in:
@@ -26,7 +26,7 @@ inputPart2 = [str|vJrwpWtwJgWrhcsFMMfFFhFp
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day2" $ do
|
||||
describe "Day3" $ do
|
||||
describe "Part1" $ do
|
||||
it "can determine Rucksack compartment contents" $ do
|
||||
splitContents simpleContents `shouldBe` ("abc", "dec")
|
||||
|
||||
35
test/Day4Spec.hs
Normal file
35
test/Day4Spec.hs
Normal file
@@ -0,0 +1,35 @@
|
||||
{-# 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
|
||||
|
||||
Reference in New Issue
Block a user