summaryrefslogtreecommitdiff
path: root/2019/Input.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-12-01 09:42:09 +0100
committertomsmeding <tom.smeding@gmail.com>2019-12-01 09:42:09 +0100
commit35f82a2aed37c8daf523ac4c9fbf7112659e8dda (patch)
treebcd2db31962d357aca764b394f4d236a1a984b4b /2019/Input.hs
parent89d19c68bdd29e06fad53d61f13df1124b98ea6a (diff)
Start 2019!
Diffstat (limited to '2019/Input.hs')
-rw-r--r--2019/Input.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/2019/Input.hs b/2019/Input.hs
new file mode 100644
index 0000000..afce44e
--- /dev/null
+++ b/2019/Input.hs
@@ -0,0 +1,20 @@
+module Input where
+
+import System.Environment
+import System.IO
+
+
+getInput :: Int -> IO [String]
+getInput day = do
+ let fname = show day ++ ".in"
+
+ args <- getArgs
+ str <- case args of
+ ["-"] -> getContents
+ [] -> readFile fname
+ _ -> do
+ hPutStrLn stderr $ "WARNING: Unrecognised command-line parameters " ++ show args ++
+ ", reading from " ++ fname
+ readFile fname
+
+ return (lines str)