Created
March 26, 2016 19:35
-
-
Save dysinger/17dfb2e6d068e2f621bc to your computer and use it in GitHub Desktop.
Prints out every dictionary word that could be a FCC ham call sign by replacing the numbers 1,3,4,0 with the letter I,E,A,O
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
| import qualified Data.Char as C | |
| import qualified Data.Set as S | |
| main :: IO () | |
| main = do | |
| let alpha = ['A' .. 'Z'] | |
| leetRegionNum = "IEAO" | |
| oneByOnes = | |
| [[a, n, b] | a <- "KNW" | |
| , n <- leetRegionNum | |
| , b <- alpha] | |
| oneByTwos = | |
| [a ++ [b] | a <- oneByOnes | |
| , b <- alpha] | |
| oneByThrees = | |
| [a ++ [b] | a <- oneByTwos | |
| , b <- alpha] | |
| twoByOnes = | |
| [[a, b, n, c] | a <- "AKNW" | |
| , b <- alpha | |
| , n <- leetRegionNum | |
| , b `S.notMember` | |
| if a == 'A' | |
| then (S.fromList "HLMNOPQRSTUVWXYZ") | |
| else (S.fromList "HLP") | |
| , c <- alpha] | |
| twoByTwos = | |
| [a ++ [b] | a <- twoByOnes | |
| , b <- alpha] | |
| twoByThrees = | |
| [a ++ [b] | a <- twoByTwos | |
| , b <- alpha] | |
| calls = | |
| S.fromList | |
| (concat | |
| [ oneByOnes | |
| , oneByTwos | |
| , oneByThrees | |
| , twoByOnes | |
| , twoByTwos | |
| , twoByThrees]) | |
| dict <- | |
| pure . S.fromList . lines . map C.toUpper . filter (/= '\'') =<< | |
| readFile "/usr/share/dict/american-english" | |
| mapM_ putStrLn (S.intersection calls dict) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output looks like: