diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-06-08 15:37:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-08 15:37:18 +0100 |
| commit | 58381184fa855c2bbd45906c3ead2d8e3f71eb35 (patch) | |
| tree | b410c72c577e92e598058ab8a41f4bd73a337411 | |
| parent | 50dd542669d77b721e8ed3867ee1dd72f9067fb4 (diff) | |
| parent | bdfdd0cb8bdc94129bd6b2ee72fa548bd4ee1e28 (diff) | |
| download | perlweeklychallenge-club-58381184fa855c2bbd45906c3ead2d8e3f71eb35.tar.gz perlweeklychallenge-club-58381184fa855c2bbd45906c3ead2d8e3f71eb35.tar.bz2 perlweeklychallenge-club-58381184fa855c2bbd45906c3ead2d8e3f71eb35.zip | |
Merge pull request #4219 from stuart-little/stuart-little_116_haskell
1st commit on 116_haskell
| -rwxr-xr-x | challenge-116/stuart-little/haskell/ch-1.hs | 15 | ||||
| -rwxr-xr-x | challenge-116/stuart-little/haskell/ch-2.hs | 13 |
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-116/stuart-little/haskell/ch-1.hs b/challenge-116/stuart-little/haskell/ch-1.hs new file mode 100755 index 0000000000..69e1d66883 --- /dev/null +++ b/challenge-116/stuart-little/haskell/ch-1.hs @@ -0,0 +1,15 @@ +#!/usr/bin/env runghc + +-- run <script> <number> + +import Data.List (inits) +import System.Environment (getArgs) + +fstRunOver :: String -> String -> [String] +fstRunOver s1 s2 = reverse $ head $ dropWhile (\xss -> (length s2) > (sum $ map length xss)) $ iterate (\xs -> (show $ (+) 1 $ (read::String->Int) $ head xs):xs) [s1] + +consecSplit :: String -> [String] +consecSplit s = head $ dropWhile (\ss -> s /= concat ss) $ map (\s'-> fstRunOver s' s) $ tail $ inits s + +main :: IO () +main = getArgs >>= putStrLn . unwords . consecSplit . head diff --git a/challenge-116/stuart-little/haskell/ch-2.hs b/challenge-116/stuart-little/haskell/ch-2.hs new file mode 100755 index 0000000000..048200b765 --- /dev/null +++ b/challenge-116/stuart-little/haskell/ch-2.hs @@ -0,0 +1,13 @@ +#!/usr/bin/env runghc + +-- run <script> <number> + +import Data.Char (digitToInt) +import Math.NumberTheory.Roots (isSquare) +import System.Environment (getArgs) + +digSqSum :: String -> Int +digSqSum = sum . map (\x-> x*x) . map digitToInt + +main :: IO () +main = getArgs >>= putStrLn . show . fromEnum . isSquare . digSqSum . head |
