day6
This commit is contained in:
parent
dbda70f3cb
commit
c83d1a920e
21
day6/main.hs
Normal file
21
day6/main.hs
Normal 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
|
Loading…
x
Reference in New Issue
Block a user