File tree 4 files changed +5
-10
lines changed
4 files changed +5
-10
lines changed Original file line number Diff line number Diff line change 1
1
import Text.Parsec
2
- import Text.Parsec.String (Parser )
3
- import Control.Applicative (liftA2 )
4
2
5
3
main :: IO ()
6
- main = interact $ (++ " \n " ) . show . liftA2 ( ,) p1 p2 . parseGames
4
+ main = interact $ (++ " \n " ) . show . (( ,) <$> p1 <*> p2) . parseGames
7
5
8
6
data Game = Game { gid :: Int , draw :: Draw } deriving Show
9
7
data Draw = Draw { red :: Int , green :: Int , blue :: Int } deriving Show
Original file line number Diff line number Diff line change 1
- import Control.Applicative (asum , liftA2 )
1
+ import Control.Applicative (asum )
2
2
import Control.Monad (guard )
3
3
import Data.Char (isDigit )
4
4
import Data.Map qualified as M
5
5
import Data.Maybe (catMaybes , isJust , fromJust , isNothing )
6
6
7
7
main :: IO ()
8
- main = interact $ (++ " \n " ) . show . liftA2 ( ,) p1 p2 . parseParts
8
+ main = interact $ (++ " \n " ) . show . (( ,) <$> p1 <*> p2) . parseParts
9
9
10
10
data Grid = Grid { rows :: [String ], my :: Int , mx :: Int }
11
11
Original file line number Diff line number Diff line change 1
1
{-# LANGUAGE LambdaCase #-}
2
2
3
- import Control.Applicative (liftA2 )
4
3
import Control.Monad.State
5
4
import Data.Map qualified as M
6
5
import Text.Parsec hiding (State )
7
- import Text.Parsec.String (Parser )
8
6
9
7
-- Use Parsec to parse, and the State monad to memoize
10
8
--
@@ -13,7 +11,7 @@ import Text.Parsec.String (Parser)
13
11
-- https://mrmr.io/memoization-in-haskell
14
12
15
13
main :: IO ()
16
- main = interact $ (++ " \n " ) . show . liftA2 ( ,) p1 p2 . parseCards
14
+ main = interact $ (++ " \n " ) . show . (( ,) <$> p1 <*> p2) . parseCards
17
15
18
16
data Card = Card { winning :: [Int ], have :: [Int ] } deriving (Show )
19
17
Original file line number Diff line number Diff line change 1
1
import Text.Parsec
2
2
import Text.Parsec.String (Parser )
3
3
import Control.Monad (void )
4
- import Control.Applicative (liftA2 )
5
4
6
5
main :: IO ()
7
- main = interact $ (++ " \n " ) . show . liftA2 ( ,) p1 p2 . parseAlmanac
6
+ main = interact $ (++ " \n " ) . show . (( ,) <$> p1 <*> p2) . parseAlmanac
8
7
9
8
data Almanac = Almanac { seeds :: [Int ], maps :: [RangesMap ] } deriving Show
10
9
type RangesMap = [RangeMap ]
You can’t perform that action at this time.
0 commit comments