day 6: remember that find exists
This commit is contained in:
parent
366b3950b3
commit
f49aab32e9
5
6-a.hs
5
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)..])
|
||||
. (+ 1)
|
||||
. fromJust . (\l -> find (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..])
|
5
6-b.hs
5
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)..])
|
||||
. (+ 1)
|
||||
. fromJust . (\l -> find (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..])
|
Loading…
Reference in New Issue