day 6: remember that find exists

This commit is contained in:
Jill 2022-12-06 10:26:56 +03:00
parent 366b3950b3
commit f49aab32e9
2 changed files with 6 additions and 4 deletions

5
6-a.hs
View File

@ -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)..])
. (+ 1)
. fromJust . (\l -> find (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..])

5
6-b.hs
View File

@ -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)..])
. (+ 1)
. fromJust . (\l -> find (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..])