aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-08-04 06:01:05 +0100
committerGitHub <noreply@github.com>2021-08-04 06:01:05 +0100
commitf4aea8fac2cee8862ccc2eb1738a5e56aa6455cb (patch)
tree83446b5d811ffe7f408b4533b259a3b07e8e11cd
parent0f55059eb11daf54c0af122d1ffb099443ee3dcb (diff)
parent2b9d1af70dce43af5a6145443060028033a62b88 (diff)
downloadperlweeklychallenge-club-f4aea8fac2cee8862ccc2eb1738a5e56aa6455cb.tar.gz
perlweeklychallenge-club-f4aea8fac2cee8862ccc2eb1738a5e56aa6455cb.tar.bz2
perlweeklychallenge-club-f4aea8fac2cee8862ccc2eb1738a5e56aa6455cb.zip
Merge pull request #4657 from stuart-little/stuart-little_124_haskell
1st commit on 124_haskell
-rwxr-xr-xchallenge-124/stuart-little/haskell/ch-1.hs30
-rwxr-xr-xchallenge-124/stuart-little/haskell/ch-2.hs14
2 files changed, 44 insertions, 0 deletions
diff --git a/challenge-124/stuart-little/haskell/ch-1.hs b/challenge-124/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..ba1ead5bd5
--- /dev/null
+++ b/challenge-124/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,30 @@
+#!/usr/bin/env runghc
+
+-- run <script>
+
+{-# LANGUAGE QuasiQuotes #-}
+import Text.RawString.QQ
+
+multi :: String
+multi = [r| ^^^^^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^ ^
+ ^^^^^
+ ^
+ ^
+ ^
+ ^^^^^
+ ^
+ ^
+|]
+
+main :: IO ()
+main = putStrLn multi
+
diff --git a/challenge-124/stuart-little/haskell/ch-2.hs b/challenge-124/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..d4fb7ff1cc
--- /dev/null
+++ b/challenge-124/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,14 @@
+#!/usr/bin/env runghc
+
+-- run <script> <space-separated numbers>
+
+import Combinatorics (tuples)
+import Data.List ((\\), )
+import Data.List.Extra (minimumOn)
+import System.Environment (getArgs)
+
+splt :: (Eq a,Num a,Ord a) => [a] -> [[a]]
+splt xs = minimumOn (\p-> abs ((sum $ head p)-(sum $ last p))) $ map (\tp-> [tp, xs\\tp]) $ tuples (div (length xs) 2) xs
+
+main :: IO ()
+main = getArgs >>= putStrLn . unlines . map unwords . (map.map) show . splt . map (read::String->Int)