Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD Haskell String Mingling Solution #219

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Functional Programming/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Functional Programming

[Fibonacci Numbers](https://github.com/swapnanildutta/Hackerrank-Codes/blob/master/Functional%20Programming/fibonacci_numbers.hs)
[Fibonacci Numbers](https://github.com/swapnanildutta/Hackerrank-Codes/blob/master/Functional%20Programming/fibonacci_numbers.hs)

[String Mingling](https://github.com/swapnanildutta/Hackerrank-Codes/blob/master/Functional%20Programming/string_mingling.hs)
43 changes: 43 additions & 0 deletions Functional Programming/string_mingling.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-- Pawel and Shaka recently became friends. They believe their friendship will last forever if they merge their favorite strings.

-- The lengths of their favorite strings are the same, . Mingling two strings, and , both of length , will result in the creation of a new string of length . It will have the following structure:

-- You are given two strings (Pawel's favorite) and (Shaka's favorite), determine the mingled string .

-- Input Format

-- The first line of input contains the string .
-- The second line contains .

-- Output Format

-- Print the mingled string, .

-- Constraints


-- The string only consists of lowercase English characters ().
-- length(P) = length(Q)

-- Sample Input #00

-- abcde
-- pqrst
-- Sample Output #00

-- apbqcrdset
-- Sample Input #01

-- hacker
-- ranker
-- Sample Output #01

-- hraacnkkeerr


ming :: String -> String -> String
ming [] [] = []
ming (x:xs) (y:ys) = x : y : ming xs ys


main = interact $ (\(x:y:_) -> ming x y) . lines