summaryrefslogtreecommitdiff
path: root/2021/Input.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-12-01 19:22:21 +0100
committerTom Smeding <tom@tomsmeding.com>2021-12-01 19:22:21 +0100
commit3dc0370ab576388b7fe6908ac73c4561551a494c (patch)
tree43276a34370552a7981946587c1f3df8b8f04020 /2021/Input.hs
parent833fcf24d661ef600d00c017ce7796b2fc938a17 (diff)
2021
Diffstat (limited to '2021/Input.hs')
-rw-r--r--2021/Input.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/2021/Input.hs b/2021/Input.hs
new file mode 100644
index 0000000..afce44e
--- /dev/null
+++ b/2021/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)