Skip to content

Instantly share code, notes, and snippets.

@u1ik
Created May 24, 2010 11:39
Show Gist options
  • Save u1ik/411776 to your computer and use it in GitHub Desktop.
Save u1ik/411776 to your computer and use it in GitHub Desktop.
-- solution for CF#14 problem A: http://codeforces.com/contest/14/problem/A?locale=en
import List
import Control.Monad
import Control.Applicative
solve rows = (reverseCols.cutCols.reverseCols.cutCols.filter notEmpty) rows
where reverseCols = map reverse
cutCols rows | all ((=='.').head) rows = cutCols $ map tail rows
| otherwise = rows
notEmpty = any (=='*')
main = do
[n, m] <- map read . words <$> getLine
rows <- replicateM n getLine
mapM_ putStrLn $ solve rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment