day15 WIP
This commit is contained in:
parent
be88678e6a
commit
2b6d44b137
|
@ -0,0 +1,32 @@
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
|
import Debug.Trace
|
||||||
|
import Data.List
|
||||||
|
import Text.Read
|
||||||
|
import Control.Arrow
|
||||||
|
import Data.List.Split
|
||||||
|
import qualified Data.Map as M
|
||||||
|
|
||||||
|
type HASH = (String, Maybe Int)
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = interact $ show . parse . init
|
||||||
|
|
||||||
|
parse :: String -> [HASH]
|
||||||
|
parse = map (second (readMaybe . tail) . break (`elem` "=-")) . splitOn ","
|
||||||
|
|
||||||
|
day15a :: String -> Int
|
||||||
|
day15a = sum . map (foldl' hashAlg 0) . splitOn ","
|
||||||
|
|
||||||
|
hashAlg :: Int -> Char -> Int
|
||||||
|
hashAlg x y = (17 * (fromEnum y + x)) `mod` 256
|
||||||
|
|
||||||
|
removeHash :: [HASH] -> HASH -> [HASH]
|
||||||
|
removeHash hs (s,n) = undefined
|
||||||
|
|
||||||
|
|
||||||
|
f1 n (x,_) = foldl hashAlg 0 x == n
|
||||||
|
f2 s (x,_) = x==s
|
||||||
|
|
||||||
|
|
||||||
|
-- input <- lines <$> readFile "testinput"
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
||||||
|
rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7
|
Loading…
Reference in New Issue
Block a user