Skip to content

Instantly share code, notes, and snippets.

@fujimura
Last active December 20, 2015 17:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujimura/6165940 to your computer and use it in GitHub Desktop.
Save fujimura/6165940 to your computer and use it in GitHub Desktop.
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