summaryrefslogtreecommitdiff
path: root/2020/Input.hs
diff options
context:
space:
mode:
Diffstat (limited to '2020/Input.hs')
-rw-r--r--2020/Input.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/2020/Input.hs b/2020/Input.hs
new file mode 100644
index 0000000..afce44e
--- /dev/null
+++ b/2020/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)