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.List
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
markerLength = 4
|
markerLength = 4
|
||||||
|
|
||||||
main = interact $
|
main = interact $
|
||||||
show
|
show
|
||||||
. (+ 1) . head
|
. (+ 1)
|
||||||
. (\l -> filter (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 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.List
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
-- literally only changes this one constant
|
-- literally only changes this one constant
|
||||||
markerLength = 14
|
markerLength = 14
|
||||||
|
|
||||||
main = interact $
|
main = interact $
|
||||||
show
|
show
|
||||||
. (+ 1) . head
|
. (+ 1)
|
||||||
. (\l -> filter (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..])
|
. fromJust . (\l -> find (\i -> markerLength == length (nub $ map (l !!) [i - (markerLength - 1) .. i])) [(markerLength - 1)..])
|
Loading…
Reference in New Issue