# Pastebin gCN5WyXI getInput :: FilePath -> IO Input getInput = parseFile (IM.fromList <$> many parseMonkey) where parseMonkey = do mn <- lexeme "Monkey" *> L.decimal <* lexeme ":" items <- lexeme "Starting items:" *> (lexeme L.decimal `sepBy` lexeme ",") op <- Operation <$> lexeme ("Operation: new = " *> lexeme val) <*> lexeme parseOp <*> lexeme val divTest <- lexeme "Test: divisible by" *> lexeme L.decimal nextTrue <- lexeme "If true: throw to monkey" *> lexeme L.decimal nextFalse <- lexeme "If false: throw to monkey" *> lexeme L.decimal let iCount = 0 pure (mn, Monkey{..}) lexeme = L.lexeme space val = (Old <$ "old") <|> (Lit <$> L.decimal) parseOp = (Times <$ "*") <|> (Plus <$ "+")