aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-067/stuart-little/haskell/ch-1.hs10
-rwxr-xr-xchallenge-067/stuart-little/haskell/ch-2.hs14
2 files changed, 24 insertions, 0 deletions
diff --git a/challenge-067/stuart-little/haskell/ch-1.hs b/challenge-067/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..1cf9e7377d
--- /dev/null
+++ b/challenge-067/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,10 @@
+#!/usr/bin/env runghc
+
+-- run <script> <max combinations_size>
+
+import System.Environment (getArgs,)
+import Combinatorics (tuples,)
+
+main = do
+ (max:size:_) <- getArgs
+ mapM_ print $ tuples (read size::Int) [1..read max::Int]
diff --git a/challenge-067/stuart-little/haskell/ch-2.hs b/challenge-067/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..bfac195f7a
--- /dev/null
+++ b/challenge-067/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,14 @@
+#!/usr/bin/env runghc
+
+-- run <script> <digit_string>
+
+import System.Environment (getArgs,)
+import Data.Maybe (fromMaybe,)
+
+combos :: Eq a => [a] -> [(a,[b])] -> [[b]]
+combos as dict = sequence $ map (fromMaybe []) $ map (flip lookup dict) as
+
+main = do
+ (nr:_) <- getArgs
+ let dict = zip ['1'..'9'] ["_@","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]
+ putStrLn $unwords $ combos nr dict