Skip to content

Instantly share code, notes, and snippets.

@tusharm
Created May 18, 2016 01:28
Show Gist options
  • Save tusharm/2c22a6858e19eeca475db5761836f0ee to your computer and use it in GitHub Desktop.
Save tusharm/2c22a6858e19eeca475db5761836f0ee to your computer and use it in GitHub Desktop.
Daily.Prog.213
module Main where
import Data.List
xor :: [Char] -> Char
xor ['x',_,'x'] = '.'
xor ['.',_,'.'] = '.'
xor [_,_,_] = 'x'
transform xs = unlines $ take 25 $ iterate step xs
step xs = map xor $ map (take 3) (filter (\x -> length(x) >= 3) $ tails $ "." ++ xs ++ ".")
main :: IO ()
main = putStrLn $ transform ".................................................x................................................"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment