42 lines
1.1 KiB
Haskell
42 lines
1.1 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Main where
|
|
|
|
import Data.Attoparsec.Text (parseOnly)
|
|
import Data.Either (fromRight)
|
|
import Options.Applicative
|
|
import qualified Data.Text.IO as T
|
|
|
|
import INAST
|
|
import INSolver
|
|
|
|
data FCInsurersOpt = FCInsurersOpt
|
|
{ path :: FilePath
|
|
, intInput :: Int
|
|
}
|
|
|
|
fCInsurersOpt :: Parser FCInsurersOpt
|
|
fCInsurersOpt = FCInsurersOpt
|
|
<$> strOption
|
|
( long "network"
|
|
<> metavar "PATH"
|
|
<> help "the path to a file that defines a network" )
|
|
<*> option auto
|
|
( long "input"
|
|
<> metavar "INT"
|
|
<> help "an integer input to the network" )
|
|
|
|
main :: IO ()
|
|
main = fcinsurers =<< execParser opts
|
|
where
|
|
opts = info (fCInsurersOpt <**> helper)
|
|
( fullDesc
|
|
<> progDesc "A small command line program that outputs a list of the \
|
|
\ fewest contributing insurers (by their integer ids)"
|
|
<> header "Fewest Contributing Insurers (in23)" )
|
|
|
|
fcinsurers :: FCInsurersOpt -> IO ()
|
|
fcinsurers (FCInsurersOpt p i) = do
|
|
inputNetwork <- T.readFile p
|
|
print $ fromRight [] $ solve i <$> parseOnly insuranceNetworkParser inputNetwork
|