This commit is contained in:
Oskar Winkels 2022-12-08 16:38:23 +01:00
parent dbda70f3cb
commit c83d1a920e
Signed by: o.winkels
GPG Key ID: E7484A06E99DAEF1
2 changed files with 22 additions and 1 deletions

View File

@ -1,4 +1,4 @@
DAY = 5
DAY = 6
DIR = day$(DAY)

21
day6/main.hs Normal file
View File

@ -0,0 +1,21 @@
import System.IO
import Data.List
marker :: Int -> Int -> String -> Int
marker p n s@(_:xs)
| unique == n = p+n
| otherwise = marker (p+1) n xs
where
unique = length $ nub $ take n s
handler :: String -> String
handler s = (show $ marker 0 4 s) ++ "\n" ++
(show $ marker 0 14 s) ++ "\n"
main :: IO ()
main = do
interact handler