Skip to content

Instantly share code, notes, and snippets.

@wuerges
Created October 9, 2018 01:45
Show Gist options
  • Save wuerges/66b2b3a6c3c5fed4ab5ba48b333d61a8 to your computer and use it in GitHub Desktop.
Save wuerges/66b2b3a6c3c5fed4ab5ba48b333d61a8 to your computer and use it in GitHub Desktop.
import Control.Applicative
import Control.Monad
fixLine [] = Nothing
fixLine (l:ls) = case l of
['O','O', _ , _ , _ ] -> Just $ ("++"++ drop 2 l) : ls
[ _ , _ , _ ,'O','O'] -> Just $ (take 3 l ++"++") : ls
_ -> (l:) <$> (fixLine ls)
main = do
n <- read <$> getLine
lines <- replicateM n getLine
case fixLine lines of
Just x -> do putStrLn "YES"
mapM_ putStrLn x
Nothing -> putStrLn "NO"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment