Created
February 4, 2010 09:40
-
-
Save 1tgr/294483 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- a, ab, abe, al, an, ana, ant, au, ay, b, ba, bag, bar, barn, bc, be, br, bs, c, cc, cf, cher, chere, cr, cs, cw, cy, d, e, ee, eg, envy, er, et, ev, ever, f, fa, ff, fn, fo, fr, ft, fur, fw, g, gh, gl, gp, gr, gum, h, ha, i, if, il, in, ing, iv, j, je, jf, jg, jm, jp, jr, js, jt, jw, k, l, m, marne, mm, mr, my, n, na, nag, nan, nh, nl, no, nor, ny, o, oe, of, on, one, onea, ont, op, or, p, pe, pf, pj, pl, pp, ps, pure, purer, q, r, rail, re, rg, ri, rire, rr, rt, s, sa, sb, se, sg, she, sj, sn, ss, st, t, tc, te, tu, ty, u, un, v, va, vat, vi, vs, vy, w, wc, we, wf, wg, wj, wr, ws, wt, wz, x, y, z, ze | |
| module Main where | |
| import Char | |
| import Control.Applicative | |
| import qualified Data.Set as Set | |
| import List | |
| lowerWords :: String -> [String] | |
| lowerWords = filter (not . null) | |
| . map (map toLower . filter isAlpha) | |
| . words | |
| readWords :: IO (Set.Set String) | |
| readWords = Set.fromList . lowerWords <$> readFile "big.txt" | |
| rot13 :: Char -> Char | |
| rot13 c = chr (((((ord c - ord 'a')) + 13) `mod` 26) + (ord 'a')) | |
| main :: IO () | |
| main = do w <- readWords | |
| let l = Set.toList (Set.intersection w (Set.map (map rot13) w)) | |
| putStrLn (concat (intersperse ", " l)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment