1234567891011121314151617181920212223242526272829303132333435 |
- module Day6Spec (spec) where
-
- import Test.Hspec
- import Day6
-
- spec :: Spec
- spec =
- describe "Day6" $ do
- describe "Part1" $ do
- it "finds unique lists" $ do
- isUnique "abc" `shouldBe` True
- isUnique "abca" `shouldBe` False
- isUnique "cabc" `shouldBe` False
- it "finds the marker in the next iteration" $ do
- findMarker' 4 3 "abc" "d" `shouldBe` Just 4
- findMarker' 4 4 "bcd" "e" `shouldBe` Just 5
- it "finds nothing if nothing is there" $ do
- findMarker "abcb" `shouldBe` Nothing
- findMarker "abcabcb" `shouldBe` Nothing
- it "finds the marker in the beginning" $ do
- findMarker "abcd" `shouldBe` Just 4
- findMarker "aabcd" `shouldBe` Just 5
- it "finds a marker" $ do
- findMarker "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 7
- findMarker "bvwbjplbgvbhsrlpgdmjqwftvncz" `shouldBe` Just 5
- findMarker "nppdvjthqldpwncqszvftbrmjlhg" `shouldBe` Just 6
- findMarker "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" `shouldBe` Just 10
- findMarker "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" `shouldBe` Just 11
- describe "Part 2" $ do
- it "finds start of message marker" $ do
- findStart "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 19
- findStart "bvwbjplbgvbhsrlpgdmjqwftvncz" `shouldBe` Just 23
- findStart "nppdvjthqldpwncqszvftbrmjlhg" `shouldBe` Just 23
- findStart "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" `shouldBe` Just 29
- findStart "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" `shouldBe` Just 26
|