2022-12-06 10:54:58 +01:00
|
|
|
module Day6Spec (spec) where
|
|
|
|
|
|
|
|
|
|
import Test.Hspec
|
|
|
|
|
import Day6
|
2022-12-06 18:14:27 +01:00
|
|
|
import qualified Data.Sequence as S
|
2022-12-06 10:54:58 +01:00
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
|
spec =
|
|
|
|
|
describe "Day6" $ do
|
|
|
|
|
describe "Part1" $ do
|
2022-12-06 18:14:27 +01:00
|
|
|
it "finds the marker just after the beginning" $ do
|
|
|
|
|
findEnd "aabcd" `shouldBe` Just 5
|
2022-12-06 10:54:58 +01:00
|
|
|
it "finds the marker in the beginning" $ do
|
2022-12-06 11:01:54 +01:00
|
|
|
findEnd "abcd" `shouldBe` Just 4
|
|
|
|
|
findEnd "aabcd" `shouldBe` Just 5
|
2022-12-06 18:14:27 +01:00
|
|
|
it "finds nothing if nothing is there" $ do
|
|
|
|
|
findEnd "abc" `shouldBe` Nothing
|
|
|
|
|
findEnd "abcb" `shouldBe` Nothing
|
|
|
|
|
findEnd "abcabcb" `shouldBe` Nothing
|
2022-12-06 10:54:58 +01:00
|
|
|
it "finds a marker" $ do
|
2022-12-06 11:01:54 +01:00
|
|
|
findEnd "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 7
|
|
|
|
|
findEnd "bvwbjplbgvbhsrlpgdmjqwftvncz" `shouldBe` Just 5
|
|
|
|
|
findEnd "nppdvjthqldpwncqszvftbrmjlhg" `shouldBe` Just 6
|
|
|
|
|
findEnd "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" `shouldBe` Just 10
|
|
|
|
|
findEnd "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" `shouldBe` Just 11
|
2022-12-06 10:54:58 +01:00
|
|
|
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
|