Cleanup Day 6 - still bad naive algorithm

This commit is contained in:
Jens Kadenbach
2022-12-06 11:01:54 +01:00
parent 3209fa9493
commit 95f13675dd
2 changed files with 26 additions and 28 deletions

View File

@@ -11,21 +11,18 @@ spec =
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
findEnd "abcb" `shouldBe` Nothing
findEnd "abcabcb" `shouldBe` Nothing
it "finds the marker in the beginning" $ do
findMarker "abcd" `shouldBe` Just 4
findMarker "aabcd" `shouldBe` Just 5
findEnd "abcd" `shouldBe` Just 4
findEnd "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
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
describe "Part 2" $ do
it "finds start of message marker" $ do
findStart "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 19