Skip to content

Instantly share code, notes, and snippets.

@atomictom
Created January 26, 2015 22:36
Show Gist options
  • Select an option

  • Save atomictom/597e83c0e4ae36bcfebf to your computer and use it in GitHub Desktop.

Select an option

Save atomictom/597e83c0e4ae36bcfebf to your computer and use it in GitHub Desktop.
import Control.Applicative
import System.Environment
main :: IO ()
main = do
n <- (read :: String -> Int) . (!!0) <$> getArgs
putStrLn $ dragon n
dragon :: Int -> String
dragon n
| n >= 0 = filter (not . (`elem` "ab")) $ iterate (concatMap replace) "Fa" !! n
| otherwise = ""
where
replace 'a' = "aRbFR"
replace 'b' = "LFaLb"
replace x = [x]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment