diff --git a/6-a.hs b/6-a.hs index 621e38d..f16ec54 100644 --- a/6-a.hs +++ b/6-a.hs @@ -1,8 +1,9 @@ import Data.List +import Data.Maybe markerLength = 4 main = interact $ show - . (+ 1) . head - . (\l -> filter (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..]) \ No newline at end of file + . (+ 1) + . fromJust . (\l -> find (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..]) \ No newline at end of file diff --git a/6-b.hs b/6-b.hs index 51a4b93..ce83b31 100644 --- a/6-b.hs +++ b/6-b.hs @@ -1,9 +1,10 @@ import Data.List +import Data.Maybe -- literally only changes this one constant markerLength = 14 main = interact $ show - . (+ 1) . head - . (\l -> filter (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..]) \ No newline at end of file + . (+ 1) + . fromJust . (\l -> find (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..]) \ No newline at end of file