summaryrefslogtreecommitdiff
path: root/2020/Input.hs
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-12-01 12:02:17 +0100
committerTom Smeding <tom.smeding@gmail.com>2020-12-01 12:02:17 +0100
commitec5353f4018c7e1ad56d521e38ec06af8d938d97 (patch)
tree27a3df1ef495ae9070d54bd7433b5c816a06c28f /2020/Input.hs
parent1fb24f91c66fb320721760a2f8fa92f1e873b4c4 (diff)
Start of 2020
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)