Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
spaghetti_and_neapolitan.hs
spaghetti :: String
spaghetti = "gtgtsgipgttptinggipsppaigsesgpetgstpatetisiesagaeaigttetepitiatsegssieeeeatepaaiagtpieataatppiitgiapsteitatiiatpetetetttgpetpaasipttssstpeeeggtiagtttegtiipestsasgpsepaasapttgattgiatppegitiatpasgatgepttggapesaeetaeissttggieietgspagesiipestipggstttpateptitiaetottissgggtttaipappgstsptttgtpispattgegstltiappseisapgistaiagteeiptptpisaieisagstapeteietgteiisgtiptstgtstasspeatspptitttatteastsgtptgtasggpniaaeteaisett"
neapolitan :: String
neapolitan = "neapolitan"
solve :: String -> String -> String
solve [] _ = ""
solve xs [] = xs
solve (x:xs) (y:ys)
| x == y = ['[', x, ']'] ++ solve xs ys
| otherwise = x:solve xs (y:ys)
main :: IO ()
main = print $ solve spaghetti neapolitan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment