|
@@ -0,0 +1,35 @@
|
|
1
|
+module Day6Spec (spec) where
|
|
2
|
+
|
|
3
|
+import Test.Hspec
|
|
4
|
+import Day6
|
|
5
|
+
|
|
6
|
+spec :: Spec
|
|
7
|
+spec =
|
|
8
|
+ describe "Day6" $ do
|
|
9
|
+ describe "Part1" $ do
|
|
10
|
+ it "finds unique lists" $ do
|
|
11
|
+ isUnique "abc" `shouldBe` True
|
|
12
|
+ isUnique "abca" `shouldBe` False
|
|
13
|
+ isUnique "cabc" `shouldBe` False
|
|
14
|
+ it "finds the marker in the next iteration" $ do
|
|
15
|
+ findMarker' 4 3 "abc" "d" `shouldBe` Just 4
|
|
16
|
+ findMarker' 4 4 "bcd" "e" `shouldBe` Just 5
|
|
17
|
+ it "finds nothing if nothing is there" $ do
|
|
18
|
+ findMarker "abcb" `shouldBe` Nothing
|
|
19
|
+ findMarker "abcabcb" `shouldBe` Nothing
|
|
20
|
+ it "finds the marker in the beginning" $ do
|
|
21
|
+ findMarker "abcd" `shouldBe` Just 4
|
|
22
|
+ findMarker "aabcd" `shouldBe` Just 5
|
|
23
|
+ it "finds a marker" $ do
|
|
24
|
+ findMarker "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 7
|
|
25
|
+ findMarker "bvwbjplbgvbhsrlpgdmjqwftvncz" `shouldBe` Just 5
|
|
26
|
+ findMarker "nppdvjthqldpwncqszvftbrmjlhg" `shouldBe` Just 6
|
|
27
|
+ findMarker "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" `shouldBe` Just 10
|
|
28
|
+ findMarker "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" `shouldBe` Just 11
|
|
29
|
+ describe "Part 2" $ do
|
|
30
|
+ it "finds start of message marker" $ do
|
|
31
|
+ findStart "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 19
|
|
32
|
+ findStart "bvwbjplbgvbhsrlpgdmjqwftvncz" `shouldBe` Just 23
|
|
33
|
+ findStart "nppdvjthqldpwncqszvftbrmjlhg" `shouldBe` Just 23
|
|
34
|
+ findStart "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" `shouldBe` Just 29
|
|
35
|
+ findStart "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" `shouldBe` Just 26
|