diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-09-02 22:11:43 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-09-02 22:11:43 +0100 |
| commit | 25b6f89a6bbb4860b072d2f20ab72d6f4e4aa57d (patch) | |
| tree | 6c76cce36b5db283bc17c8e041453c8852c32d9b /challenge-285/ulrich-rieke/haskell/ch-1.hs | |
| parent | 5700092f38ceae57dc000f4f9538207779dcf643 (diff) | |
| download | perlweeklychallenge-club-25b6f89a6bbb4860b072d2f20ab72d6f4e4aa57d.tar.gz perlweeklychallenge-club-25b6f89a6bbb4860b072d2f20ab72d6f4e4aa57d.tar.bz2 perlweeklychallenge-club-25b6f89a6bbb4860b072d2f20ab72d6f4e4aa57d.zip | |
- Added solutions by Ulrich Rieke.
- Added solutions by Paulo Custodio.
- Added solutions by David Ferrone.
- Added solutions by W. Luis Mochan.
Diffstat (limited to 'challenge-285/ulrich-rieke/haskell/ch-1.hs')
| -rwxr-xr-x | challenge-285/ulrich-rieke/haskell/ch-1.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-285/ulrich-rieke/haskell/ch-1.hs b/challenge-285/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..0ddcd35d73 --- /dev/null +++ b/challenge-285/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,19 @@ +module Challenge285
+ where
+import Data.List.Split ( splitOn )
+
+solution :: String -> String
+solution input =
+ let routes = splitOn "," input
+ routepairs = map (\li -> (head li , last li ) ) $ map ( concat .
+ splitOn " " ) routes
+ starts = map fst routepairs
+ destinations = map snd routepairs
+ in filter (\dest -> notElem dest starts ) destinations
+
+main :: IO ( )
+main = do
+ putStrLn "Enter some routes, separated by ','!"
+ putStrLn "Separate start and destination by a blank!"
+ allRoutes <- getLine
+ print $ solution allRoutes
|
