3
\$\begingroup\$

Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers.

2 = A, B, C
3 = D, E, F
4 = G, H, I
5 = J, K, L
6 = M, N, O
7 = P, Q, R, S
8 = T, U, V
9 = W, X, Y, Z

No letters are associated with the number 0 or 1.

Your challenge: Given any phone number in seven-digit or ten-digit format, return English words or phrases into which it could be translated using the code above. Spaces do not matter.

So, for example 873-5377 can be translated to “useless” or “trek-err” and possibly a few others depending on your words list.

For the purposes of this contest,

  1. All digits in the phone number must be used and must be translated into letters. This means that phone numbers containing 0s or 1s can not be translated.

  2. If your operating system or programming environment has a built-in words list (/usr/share/dict/words or the equivalent), go ahead and use it. Otherwise, you can assume that a word list has been downloaded to a convenient directory. However, (a) no-preprocessing of the dictionary to limit it to seven and ten letter words or anything like that, and (b) you have to open the dictionary and load the words yourself; you can’t just pass a variable that contains a list of words.

  3. If your dictionary includes proper nouns, it’s OK to have them in your output.

  4. You can not assume that your input is an integer. The number 213-867-5309 might be input as (213) 867-5409 or 2138675309. Strip all non-numerical characters and make sure what’s left is a seven or ten-digit integer.

  5. Your answer can be a function or a complete program, but no snippets.

FOR EXTRA CREDIT

  1. You may implement a version of the code that replaces rule 1 with a more forgiving test — you may leave up to 2 numbers as numbers while changing all the other numbers to words. If you choose this path, the code must complete a comprehensive search and not do something trivial like leaving the first two numbers as numbers while doing word substitution on the rest. Obviously in this variation, phone numbers with up to two 0s and 1s may be translated.

Using the same test number as above, rule 6 gives us the answers "us-elf-77", "us-ekes-7", and others in addition to the answers above.

TEST NUMBERS

Show us what you get for 868-454-6523 and 323-454-6503.

SCORING

Shortest code wins, but if you’ve implemented rule 6 you can cut your length in half. I also plan to call out interesting solutions or solutions from verbose languages that might have won if their command names were shorter.

\$\endgroup\$
  • 3
    \$\begingroup\$ Related. \$\endgroup\$ – Arnauld Apr 1 at 14:35
  • 3
    \$\begingroup\$ I think the scoring section needs to be deleted on this one... not only does it give a bonus, the criterion is not objective therefore this should not be scored by length. \$\endgroup\$ – Magic Octopus Urn Apr 1 at 18:16
  • 2
    \$\begingroup\$ What do you mean by "you have to open the dictionary and load the words yourself; you can’t just pass a variable that contains a list of words."? Is a function argument that contains the words enough or do we need to read from an I/O stream? \$\endgroup\$ – Erik the Outgolfer Apr 1 at 18:21
  • 3
    \$\begingroup\$ @MichaelStern Simply because anyone reading from the linux dictionary may have a shorter byte-count than someone trying to encode words or something. Nobody is writing code that can be objectively compared for this challenge because we may be using different word sources. Therefore the inputs and outputs for each piece of code are not the same, which is basically saying it's not explicitly objective. 6 exacerbates this. \$\endgroup\$ – Magic Octopus Urn Apr 1 at 18:32
  • 4
    \$\begingroup\$ I like the idea of this, but it feels like there's too many different things going into it here, and having test cases without given outputs doesn't help. It'd be one thing if this was take a phone number in the most convenient format and check a list of phrases from input to see if they fit, but this is clean up and validate a phone number, load a dictionary from the file system, check the number against every possible phrase from it, and output everything that fits, with a -50% bonus for allowing 1 or 2 numbers to be left out of the phrase. Again, I like the idea, but it needs trimming. \$\endgroup\$ – Unrelated String Apr 1 at 18:53
5
\$\begingroup\$

05AB1E, 207 bytes

þ"! ! ABC DEF GHI JKL MNO PQRS TUV WXYZ"S#sSèU
"€‚ƒ„…†‡ˆ‰Š‹ŒŽ•–—™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîï"©vyV®vYy«"“ÿ“".Vu}})
ʒg¹þgQ}
ʒ´vXNèyåˆ}¯P}
¹þg7Q¹þgTQ&i´¯}

Try it online!

(1) The first line of the code, will replace each number in the input with the corresponding set of possible letters.

þ                                              # Only digits of input.
 "! ! ABC DEF GHI JKL MNO PQRS TUV WXYZ"       # Push keypad letters.
                                        S#     # Split into list and on spaces.
                                          sS   # Split input into digits.
                                            èU # Push indexes of digits and store in X.

(2) The second line of the code, will push every possible dictionary word that is stored in 05AB1E. It accomplishes this by pushing all pairings of the dictionary encrypted characters and converting them to their dictionary stored equivalents. There are 100 unique dictionary characters, and 100*100 unique pairs of them. This means we are getting access to a total of 10,000 words from the 05AB1E dictionary.

(3) The third line of the code, will filter the dictionary by the length of the number of digits in the input.

(4) The fourth line of the code, will filter again the words from the dictionary which match the filter of possible letters outlined by line #1.

(5) The final line of the code, will simply return an empty array provided that the input was not 7 or 10 digits long after parsing.


Using no external libraries/files, this code can detect any word that is in the 05AB1E dictionary. More specifically, if the input is limited to 7 characters the following list:

["ABILITY", "ABRAHAM", "ABSENCE", "ACADEMY", "ACCEPTS", "ACCOUNT", "ACCUSED", "ACHIEVE", "ACQUIRE", "ACROBAT", "ACRYLIC", "ACTIONS", "ACTRESS", "ADAPTED", "ADAPTER", "ADAPTOR", "ADDRESS", "ADOPTED", "ADVANCE", "ADVERSE", "ADVISED", "ADVISOR", "AFFAIRS", "AFFECTS", "AFRICAN", "AGAINST", "AIRFARE", "AIRLINE", "AIRPORT", "ALABAMA", "ALBANIA", "ALBERTA", "ALCOHOL", "ALGEBRA", "ALGERIA", "ALLEGED", "ALLERGY", "ALLOWED", "ALREADY", "ALTERED", "AMATEUR", "AMAZING", "AMBIENT", "AMENDED", "AMERICA", "AMONGST", "AMOUNTS", "AMPLAND", "ANAHEIM", "ANALYST", "ANALYZE", "ANATOMY", "ANCIENT", "ANDORRA", "ANDREAS", "ANDREWS", "ANGELES", "ANIMALS", "ANOTHER", "ANSWERS", "ANTENNA", "ANTHONY", "ANTIGUA", "ANTIQUE", "ANTONIO", "ANXIETY", "ANYBODY", "ANYMORE", "ANYTIME", "APPAREL", "APPEALS", "APPEARS", "APPLIED", "APPLIES", "APPROVE", "AQUATIC", "ARCHIVE", "ARISING", "ARIZONA", "ARMENIA", "ARRANGE", "ARRIVAL", "ARRIVED", "ARRIVES", "ARTICLE", "ARTISTS", "ARTWORK", "ASPECTS", "ASSAULT", "ASSISTS", "ASSUMED", "ASSUMES", "ASSURED", "ATLANTA", "ATTACKS", "ATTEMPT", "ATTRACT", "AUCTION", "AUDITOR", "AUSTRIA", "AUTHORS", "AVERAGE", "AWARDED", "AWESOME", "BACKING", "BAGHDAD", "BAHAMAS", "BAHRAIN", "BALANCE", "BALLOON", "BANGBUS", "BANGKOK", "BANKING", "BANNERS", "BAPTIST", "BARBARA", "BARGAIN", "BARRIER", "BASKETS", "BATTERY", "BEACHES", "BEARING", "BEATLES", "BECAUSE", "BECOMES", "BEDDING", "BEDFORD", "BEDROOM", "BEIJING", "BELARUS", "BELFAST", "BELGIUM", "BELIEFS", "BELIEVE", "BELONGS", "BENEATH", "BENEFIT", "BENNETT", "BERMUDA", "BERNARD", "BESIDES", "BETTING", "BETWEEN", "BEVERLY", "BICYCLE", "BIDDING", "BIGGEST", "BILLING", "BILLION", "BINDING", "BIOLOGY", "BIZARRE", "BIZRATE", "BLANKET", "BLESSED", "BLOCKED", "BLOGGER", "BLOWING", "BLOWJOB", "BOATING", "BOLIVIA", "BONDAGE", "BOOKING", "BOOLEAN", "BORDERS", "BOROUGH", "BOTTLES", "BOULDER", "BOUQUET", "BOWLING", "BRACKET", "BRADLEY", "BRANDON", "BREASTS", "BRIDGES", "BRIEFLY", "BRISTOL", "BRITAIN", "BRITISH", "BRITNEY", "BROADER", "BROKERS", "BROTHER", "BROUGHT", "BROWSER", "BUDGETS", "BUFFALO", "BUILDER", "BUKKAKE", "BURNING", "BUTTONS", "CABINET", "CALCIUM", "CALGARY", "CALLING", "CAMERAS", "CAMERON", "CAMPING", "CANDLES", "CAPABLE", "CAPITAL", "CAPITOL", "CAPTAIN", "CAPTURE", "CARDIAC", "CARDIFF", "CAREERS", "CAREFUL", "CARRIED", "CARRIER", "CARRIES", "CARROLL", "CARTOON", "CASINOS", "CASTING", "CATALOG", "CAUSING", "CAUTION", "CEILING", "CENTERS", "CENTRAL", "CENTRES", "CENTURY", "CERAMIC", "CERTAIN", "CHAMBER", "CHANCES", "CHANGED", "CHANGES", "CHANNEL", "CHAPTER", "CHARGED", "CHARGER", "CHARGES", "CHARITY", "CHARLES", "CHARLIE", "CHARTER", "CHASSIS", "CHEAPER", "CHECKED", "CHELSEA", "CHESTER", "CHICAGO", "CHICKEN", "CHINESE", "CHOICES", "CHRONIC", "CIRCLES", "CIRCUIT", "CITIZEN", "CLAIMED", "CLARITY", "CLASSES", "CLASSIC", "CLEANER", "CLEANUP", "CLEARED", "CLEARLY", "CLIENTS", "CLIMATE", "CLINICS", "CLINTON", "CLOSELY", "CLOSEST", "CLOSING", "CLOSURE", "CLOTHES", "CLUSTER", "COACHES", "COASTAL", "COATING", "COLEMAN", "COLLECT", "COLLEGE", "COLLINS", "COLOGNE", "COLORED", "COLOURS", "COLUMNS", "COMBINE", "COMFORT", "COMMAND", "COMMENT", "COMMONS", "COMPACT", "COMPANY", "COMPARE", "COMPETE", "COMPILE", "COMPLEX", "COMPUTE", "CONCEPT", "CONCERN", "CONCERT", "CONCORD", "CONDUCT", "CONFIRM", "CONNECT", "CONSENT", "CONSIST", "CONSOLE", "CONSULT", "CONTACT", "CONTAIN", "CONTENT", "CONTEST", "CONTEXT", "CONTROL", "CONVERT", "COOKIES", "COOKING", "COOLING", "COPYING", "CORNELL", "CORNERS", "CORRECT", "COSTUME", "COTTAGE", "COUNCIL", "COUNSEL", "COUNTED", "COUNTER", "COUNTRY", "COUPLED", "COUPLES", "COUPONS", "COURAGE", "COURIER", "COURSES", "COVERED", "CREATED", "CREATES", "CREATOR", "CREDITS", "CRICKET", "CRITICS", "CROATIA", "CRUCIAL", "CRUISES", "CRYSTAL", "CUISINE", "CULTURE", "CUMSHOT", "CURIOUS", "CURRENT", "CUSTODY", "CUSTOMS", "CUTTING", "CYCLING", "DAMAGED", "DAMAGES", "DANCING", "DEALERS", "DEALING", "DEBORAH", "DECADES", "DECIDED", "DECIMAL", "DECLARE", "DECLINE", "DEFAULT", "DEFECTS", "DEFENCE", "DEFENSE", "DEFICIT", "DEFINED", "DEFINES", "DEGREES", "DELAYED", "DELETED", "DELIGHT", "DELIVER", "DEMANDS", "DENMARK", "DENSITY", "DEPENDS", "DEPOSIT", "DERIVED", "DESERVE", "DESIGNS", "DESIRED", "DESKTOP", "DESPITE", "DESTINY", "DESTROY", "DETAILS", "DETROIT", "DEUTSCH", "DEVELOP", "DEVIANT", "DEVICES", "DEVOTED", "DIAGRAM", "DIAMOND", "DIETARY", "DIGITAL", "DIPLOMA", "DISABLE", "DISCUSS", "DISEASE", "DISPLAY", "DISPUTE", "DISTANT", "DIVERSE", "DIVIDED", "DIVORCE", "DOCTORS", "DOLLARS", "DOMAINS", "DONATED", "DOUGLAS", "DRAWING", "DRESSED", "DRESSES", "DRIVERS", "DRIVING", "DROPPED", "DURABLE", "DYNAMIC", "EARLIER", "EARNING", "EASTERN", "ECLIPSE", "ECOLOGY", "ECONOMY", "ECUADOR", "EDITING", "EDITION", "EDITORS", "EDWARDS", "EFFECTS", "EFFORTS", "ELDERLY", "ELECTED", "ELECTRO", "ELEGANT", "ELEMENT", "ELLIOTT", "EMBASSY", "EMERALD", "EMPEROR", "ENABLED", "ENABLES", "ENDLESS", "ENEMIES", "ENGAGED", "ENGINES", "ENGLAND", "ENGLISH", "ENHANCE", "ENJOYED", "ENLARGE", "ENQUIRY", "ENSURES", "ENTERED", "ENTRIES", "EPISODE", "EQUALLY", "EROTICA", "ESCORTS", "ESSENCE", "ESTATES", "ESTONIA", "ETERNAL", "ETHICAL", "EVENING", "EVIDENT", "EXACTLY", "EXAMINE", "EXAMPLE", "EXCERPT", "EXCITED", "EXCLUDE", "EXECUTE", "EXHAUST", "EXHIBIT", "EXISTED", "EXPECTS", "EXPEDIA", "EXPENSE", "EXPERTS", "EXPIRED", "EXPIRES", "EXPLAIN", "EXPLORE", "EXPORTS", "EXPOSED", "EXPRESS", "EXTENDS", "EXTRACT", "EXTREME", "FABRICS", "FACTORS", "FACTORY", "FACULTY", "FAILING", "FAILURE", "FALLING", "FANTASY", "FARMERS", "FARMING", "FASHION", "FASTEST", "FATHERS", "FEATURE", "FEDERAL", "FEEDING", "FEELING", "FEMALES", "FERRARI", "FICTION", "FIFTEEN", "FIGHTER", "FIGURED", "FIGURES", "FILLING", "FILTERS", "FINALLY", "FINANCE", "FINDING", "FINDLAW", "FINGERS", "FINLAND", "FINNISH", "FIREFOX", "FISHING", "FISTING", "FITNESS", "FITTING", "FLIGHTS", "FLORIDA", "FLORIST", "FLOWERS", "FOCUSED", "FOCUSES", "FOLDERS", "FOLDING", "FOLLOWS", "FOOTAGE", "FOREIGN", "FORESTS", "FOREVER", "FORMATS", "FORMING", "FORMULA", "FORTUNE", "FORWARD", "FOUNDED", "FOUNDER", "FRAMING", "FRANCIS", "FREEBSD", "FREEDOM", "FREIGHT", "FRIENDS", "FUCKING", "FUJITSU", "FUNDING", "FUNERAL", "FURTHER", "FUTURES", "GABRIEL", "GADGETS", "GALLERY", "GARBAGE", "GARDENS", "GATEWAY", "GAZETTE", "GENERAL", "GENERIC", "GENESIS", "GENETIC", "GENUINE", "GEOLOGY", "GEORGIA", "GERMANY", "GETTING", "GILBERT", "GLASGOW", "GLASSES", "GLUCOSE", "GOURMET", "GRAMMAR", "GRANTED", "GRAPHIC", "GRATUIT", "GRAVITY", "GREATER", "GREATLY", "GREGORY", "GRENADA", "GRIFFIN", "GROCERY", "GROUNDS", "GROWING", "GUITARS", "HABITAT", "HALIFAX", "HAMBURG", "HAMPTON", "HANDJOB", "HANDLED", "HANDLES", "HANGING", "HAPPENS", "HARBOUR", "HARMFUL", "HARMONY", "HARVARD", "HARVEST", "HAZARDS", "HEADERS", "HEADING", "HEADSET", "HEALING", "HEALTHY", "HEARING", "HEATHER", "HEATING", "HEAVILY", "HEIGHTS", "HELPFUL", "HELPING", "HERSELF", "HEWLETT", "HIGHEST", "HIGHWAY", "HIMSELF", "HISTORY", "HITACHI", "HITTING", "HOBBIES", "HOLDERS", "HOLDING", "HOLIDAY", "HOLLAND", "HOPKINS", "HORIZON", "HORMONE", "HOSTELS", "HOSTING", "HOTMAIL", "HOTTEST", "HOUSING", "HOUSTON", "HOWEVER", "HUNDRED", "HUNGARY", "HUNTING", "HUSBAND", "HYGIENE", "HYUNDAI", "ICELAND", "IGNORED", "ILLEGAL", "ILLNESS", "IMAGINE", "IMAGING", "IMPACTS", "IMPLIED", "IMPLIES", "IMPORTS", "IMPOSED", "IMPROVE", "INCLUDE", "INDEXED", "INDEXES", "INDIANA", "INDIANS", "INDICES", "INDUCED", "INFANTS", "INITIAL", "INJURED", "INQUIRE", "INQUIRY", "INSECTS", "INSIDER", "INSIGHT", "INSTALL", "INSTANT", "INSTEAD", "INSULIN", "INSURED", "INTEGER", "INTENSE", "INTERIM", "INVALID", "INVITED", "INVOICE", "INVOLVE", "IRELAND", "ISLAMIC", "ISLANDS", "ISRAELI", "ITALIAN", "JACKETS", "JACKSON", "JAMAICA", "JANUARY", "JEFFREY", "JELSOFT", "JESSICA", "JEWELRY", "JOHNSON", "JOINING", "JOURNAL", "JOURNEY", "JUMPING", "JUSTICE", "JUSTIFY", "KARAOKE", "KATRINA", "KEEPING", "KENNEDY", "KENNETH", "KEYWORD", "KILLING", "KINGDOM", "KISSING", "KITCHEN", "KNIGHTS", "KNOWING", "LABELED", "LANDING", "LAPTOPS", "LARGELY", "LARGEST", "LASTING", "LATINAS", "LAUNDRY", "LAWSUIT", "LAWYERS", "LEADERS", "LEADING", "LEARNED", "LEASING", "LEATHER", "LEAVING", "LEBANON", "LECTURE", "LEGALLY", "LEGENDS", "LEISURE", "LENDERS", "LENDING", "LEONARD", "LESBIAN", "LESSONS", "LETTERS", "LETTING", "LEVITRA", "LEXMARK", "LIBERAL", "LIBERIA", "LIBERTY", "LIBRARY", "LICENCE", "LICENSE", "LICKING", "LIGHTER", "LIMITED", "LINCOLN", "LINDSAY", "LINKING", "LISTING", "LIVECAM", "LIVESEX", "LOADING", "LOCALLY", "LOCATED", "LOCATOR", "LOCKING", "LODGING", "LOGGING", "LOGICAL", "LONGEST", "LOOKING", "LOTTERY", "LUGGAGE", "MACHINE", "MADISON", "MADNESS", "MADONNA", "MAGICAL", "MAILING", "MAILMAN", "MANAGED", "MANAGER", "MANDATE", "MANUALS", "MAPPING", "MARILYN", "MARKERS", "MARKETS", "MARKING", "MARRIED", "MARTIAL", "MASSAGE", "MASSIVE", "MASTERS", "MATCHED", "MATCHES", "MATTERS", "MATTHEW", "MAXIMUM", "MEANING", "MEASURE", "MEDICAL", "MEDLINE", "MEETING", "MELISSA", "MEMBERS", "MEMPHIS", "MENTION", "MERCURY", "MESSAGE", "METHODS", "MEXICAN", "MICHAEL", "MIDWEST", "MILEAGE", "MILLION", "MINERAL", "MINIMAL", "MINIMUM", "MINOLTA", "MINUTES", "MIRACLE", "MIRRORS", "MISSILE", "MISSING", "MISSION", "MISTAKE", "MIXTURE", "MOBILES", "MODULAR", "MODULES", "MOLDOVA", "MOMENTS", "MONITOR", "MONSTER", "MONTANA", "MONTHLY", "MORNING", "MOROCCO", "MOTHERS", "MOUNTED", "MOZILLA", "MUSCLES", "MUSEUMS", "MUSICAL", "MUSLIMS", "MUSTANG", "MYANMAR", "MYSIMON", "MYSPACE", "MYSTERY", "NAMIBIA", "NATIONS", "NATURAL", "NAUGHTY", "NEAREST", "NEITHER", "NERVOUS", "NETWORK", "NEUTRAL", "NEWPORT", "NIAGARA", "NIGERIA", "NIPPLES", "NIRVANA", "NORFOLK", "NOTHING", "NOTICED", "NOTICES", "NOVELTY", "NOWHERE", "NUCLEAR", "NUMBERS", "NUMERIC", "NURSERY", "NURSING", "OAKLAND", "OBESITY", "OBJECTS", "OBSERVE", "OBVIOUS", "OCTOBER", "OFFENSE", "OFFERED", "OFFICER", "OFFICES", "OFFLINE", "OLYMPIC", "OLYMPUS", "ONGOING", "ONTARIO", "OPENING", "OPERATE", "OPINION", "OPPOSED", "OPTICAL", "OPTIMAL", "OPTIMUM", "OPTIONS", "ORDERED", "ORGANIC", "ORIGINS", "ORLANDO", "ORLEANS", "OUTCOME", "OUTDOOR", "OUTLETS", "OUTLINE", "OUTLOOK", "OUTPUTS", "OUTSIDE", "OVERALL", "PACIFIC", "PACKAGE", "PACKARD", "PACKETS", "PACKING", "PAINFUL", "PAINTED", "PANTIES", "PARENTS", "PARKING", "PARTIAL", "PARTIES", "PARTNER", "PASSAGE", "PASSING", "PASSION", "PASSIVE", "PATCHES", "PATENTS", "PATIENT", "PATRICK", "PATTERN", "PAYABLE", "PAYMENT", "PAYROLL", "PENALTY", "PENDANT", "PENDING", "PENGUIN", "PENSION", "PENTIUM", "PEOPLES", "PERCENT", "PERFECT", "PERFORM", "PERFUME", "PERHAPS", "PERIODS", "PERMITS", "PERSIAN", "PERSONS", "PHANTOM", "PHILIPS", "PHOENIX", "PHRASES", "PHYSICS", "PICKING", "PICTURE", "PIONEER", "PIRATES", "PISSING", "PLACING", "PLANETS", "PLANNED", "PLANNER", "PLASTIC", "PLAYBOY", "PLAYERS", "PLAYING", "PLEASED", "PLUGINS", "POCKETS", "PODCAST", "POINTED", "POINTER", "POKEMON", "POLYMER", "PONTIAC", "POPULAR", "PORSCHE", "PORTION", "POSSESS", "POSTAGE", "POSTERS", "POSTING", "POTTERY", "POULTRY", "POVERTY", "POWERED", "PRAIRIE", "PRAYERS", "PRECISE", "PREDICT", "PREFERS", "PREMIER", "PREMIUM", "PREPAID", "PREPARE", "PRESENT", "PRESSED", "PRESTON", "PREVENT", "PREVIEW", "PRICING", "PRIMARY", "PRINTED", "PRINTER", "PRIVACY", "PRIVATE", "PROBLEM", "PROCEED", "PROCESS", "PRODUCE", "PRODUCT", "PROFILE", "PROFITS", "PROGRAM", "PROJECT", "PROMISE", "PROMOTE", "PROPHET", "PROPOSE", "PROTECT", "PROTEIN", "PROTEST", "PROUDLY", "PROVIDE", "PUBLISH", "PULLING", "PURPOSE", "PURSUIT", "PUSHING", "PUTTING", "PUZZLES", "QUALIFY", "QUALITY", "QUANTUM", "QUARTER", "QUERIES", "QUICKLY", "QUIZZES", "RADICAL", "RAILWAY", "RAINBOW", "RAISING", "RALEIGH", "RANGERS", "RANGING", "RANKING", "RAPIDLY", "RATINGS", "RAYMOND", "REACHED", "REACHES", "READERS", "READILY", "READING", "REALITY", "REALIZE", "REALTOR", "REASONS", "REBATES", "REBECCA", "REBOUND", "RECEIPT", "RECEIVE", "RECIPES", "RECORDS", "RECOVER", "REDHEAD", "REDUCED", "REDUCES", "REFINED", "REFLECT", "REFORMS", "REFRESH", "REFUSED", "REGARDS", "REGIONS", "REGULAR", "RELATED", "RELATES", "RELEASE", "RELYING", "REMAINS", "REMARKS", "REMOVAL", "REMOVED", "RENEWAL", "RENTALS", "REPAIRS", "REPLACE", "REPLICA", "REPLIED", "REPLIES", "REPORTS", "REPRINT", "REQUEST", "REQUIRE", "RESERVE", "RESOLVE", "RESORTS", "RESPECT", "RESPOND", "RESTORE", "RESULTS", "RESUMES", "RETIRED", "RETREAT", "RETURNS", "REUNION", "REUTERS", "REVEALS", "REVENGE", "REVENUE", "REVERSE", "REVIEWS", "REVISED", "REWARDS", "RICHARD", "ROBERTS", "ROLLING", "ROMANCE", "ROMANIA", "ROUGHLY", "ROUTERS", "ROUTINE", "ROUTING", "ROYALTY", "RUNNING", "RUNTIME", "RUSSELL", "RUSSIAN", "SAILING", "SAMPLES", "SAMSUNG", "SATISFY", "SAVINGS", "SCANNED", "SCANNER", "SCHEMES", "SCHOLAR", "SCHOOLS", "SCIENCE", "SCORING", "SCRATCH", "SCREENS", "SCRIPTS", "SEAFOOD", "SEASONS", "SEATING", "SEATTLE", "SECONDS", "SECRETS", "SECTION", "SECTORS", "SECURED", "SEEKERS", "SEEKING", "SEGMENT", "SELLERS", "SELLING", "SEMINAR", "SENATOR", "SENDING", "SENEGAL", "SENIORS", "SENSORS", "SERIOUS", "SERVERS", "SERVICE", "SERVING", "SESSION", "SETTING", "SETTLED", "SEVENTH", "SEVERAL", "SHADOWS", "SHAKIRA", "SHANNON", "SHARING", "SHELTER", "SHEMALE", "SHERIFF", "SHERMAN", "SHIPPED", "SHOPPER", "SHORTER", "SHORTLY", "SHOWERS", "SHOWING", "SHUTTLE", "SIEMENS", "SIGNALS", "SIGNING", "SILENCE", "SILICON", "SIMILAR", "SIMPSON", "SINGING", "SINGLES", "SISTERS", "SITEMAP", "SITTING", "SKATING", "SKILLED", "SMALLER", "SMILIES", "SMOKING", "SOCIETY", "SOLARIS", "SOLDIER", "SOLOMON", "SOLVING", "SOMALIA", "SOMEHOW", "SOMEONE", "SOONEST", "SOURCES", "SPANISH", "SPATIAL", "SPEAKER", "SPECIAL", "SPECIES", "SPECIFY", "SPENCER", "SPIRITS", "SPONSOR", "SPRINGS", "SPYWARE", "STADIUM", "STANLEY", "STARTED", "STARTER", "STARTUP", "STATING", "STATION", "STATUTE", "STAYING", "STEPHEN", "STEVENS", "STEWART", "STICKER", "STOMACH", "STOPPED", "STORAGE", "STORIES", "STRANGE", "STREAMS", "STREETS", "STRETCH", "STRIKES", "STRINGS", "STRIPES", "STUDENT", "STUDIED", "STUDIES", "STUDIOS", "STUFFED", "STYLISH", "SUBJECT", "SUBLIME", "SUCCEED", "SUCCESS", "SUCKING", "SUGGEST", "SUICIDE", "SUMMARY", "SUNRISE", "SUPPORT", "SUPPOSE", "SUPREME", "SURFACE", "SURFING", "SURGEON", "SURGERY", "SURNAME", "SURPLUS", "SURVEYS", "SURVIVE", "SUSPECT", "SWEDISH", "SYMBOLS", "SYSTEMS", "TABLETS", "TACTICS", "TALKING", "TARGETS", "TEACHER", "TEACHES", "TEENAGE", "TELECOM", "TELLING", "TENSION", "TERRACE", "TERRAIN", "TESTING", "TEXTILE", "TEXTURE", "THEATER", "THEATRE", "THEOREM", "THERAPY", "THEREBY", "THEREOF", "THERMAL", "THOMSON", "THOUGHT", "THREADS", "THREATS", "THROUGH", "THUNDER", "TICKETS", "TIFFANY", "TIMOTHY", "TOBACCO", "TODDLER", "TONIGHT", "TOOLBAR", "TOOLBOX", "TOOLKIT", "TOPLESS", "TORONTO", "TORTURE", "TOSHIBA", "TOTALLY", "TOUCHED", "TOURING", "TOURISM", "TOURIST", "TOWARDS", "TRACKED", "TRACKER", "TRACTOR", "TRADING", "TRAFFIC", "TRAGEDY", "TRAILER", "TRAINED", "TRAINER", "TRANSIT", "TRAVELS", "TREATED", "TRIBUNE", "TRIBUTE", "TRIGGER", "TRINITY", "TRIUMPH", "TROUBLE", "TRUSTED", "TRUSTEE", "TSUNAMI", "TUESDAY", "TUITION", "TUNISIA", "TURKISH", "TURNING", "TWISTED", "TYPICAL", "UKRAINE", "UNIFIED", "UNIFORM", "UNKNOWN", "UNUSUAL", "UPDATED", "UPDATES", "UPGRADE", "UPSKIRT", "URUGUAY", "USUALLY", "UTILITY", "UTILIZE", "VACCINE", "VAMPIRE", "VANILLA", "VARIETY", "VARIOUS", "VARYING", "VATICAN", "VEHICLE", "VENDORS", "VENTURE", "VERIZON", "VERMONT", "VERSION", "VESSELS", "VETERAN", "VICTIMS", "VICTORY", "VIETNAM", "VIEWERS", "VIEWING", "VILLAGE", "VINCENT", "VINTAGE", "VIOLENT", "VIRTUAL", "VIRUSES", "VISIBLE", "VISITED", "VISITOR", "VITAMIN", "VOLTAGE", "VOLUMES", "WAITING", "WALKING", "WALLACE", "WANTING", "WARMING", "WARNING", "WARRANT", "WARRIOR", "WASHING", "WATCHED", "WATCHES", "WEAPONS", "WEARING", "WEATHER", "WEBCAMS", "WEBCAST", "WEBLOGS", "WEBPAGE", "WEBSITE", "WEBSTER", "WEDDING", "WEEKEND", "WEIGHTS", "WELCOME", "WELDING", "WELFARE", "WESTERN", "WHEREAS", "WHETHER", "WICHITA", "WILLIAM", "WILLING", "WINDOWS", "WINDSOR", "WINNERS", "WINNING", "WINSTON", "WISHING", "WITHOUT", "WITNESS", "WORKERS", "WORKING", "WORKOUT", "WORRIED", "WORSHIP", "WRAPPED", "WRITERS", "WRITING", "WRITTEN", "WYOMING", "YOUNGER", "ZEALAND"]

For 10 characters, you'd be able to detect:

["ABORIGINAL", "ABSOLUTELY", "ABSORPTION", "ACCEPTABLE", "ACCEPTANCE", "ACCESSIBLE", "ACCOMPLISH", "ACCORDANCE", "ACCOUNTING", "ACCREDITED", "ACCURATELY", "ACDBENTITY", "ACTIVATION", "ACTIVITIES", "ADAPTATION", "ADDITIONAL", "ADDRESSING", "ADJUSTABLE", "ADJUSTMENT", "ADMISSIONS", "ADOLESCENT", "ADVANTAGES", "ADVENTURES", "ADVERTISER", "AFFILIATED", "AFFILIATES", "AFFORDABLE", "AFTERWARDS", "AGGRESSIVE", "AGREEMENTS", "ALEXANDRIA", "ALGORITHMS", "ALLOCATION", "AMBASSADOR", "AMENDMENTS", "ANALYTICAL", "ANNOTATION", "ANTARCTICA", "ANTIBODIES", "APARTMENTS", "APPARENTLY", "APPEARANCE", "APPLIANCES", "APPLICABLE", "APPLICANTS", "APPRECIATE", "APPROACHES", "ARCHITECTS", "ARTIFICIAL", "ASSESSMENT", "ASSIGNMENT", "ASSISTANCE", "ASSOCIATED", "ASSOCIATES", "ASSUMPTION", "ATMOSPHERE", "ATTACHMENT", "ATTEMPTING", "ATTENDANCE", "ATTRACTION", "ATTRACTIVE", "ATTRIBUTES", "AUSTRALIAN", "AUTHORIZED", "AUTOMATION", "AUTOMOBILE", "AUTOMOTIVE", "AZERBAIJAN", "BACKGROUND", "BANGLADESH", "BANKRUPTCY", "BASKETBALL", "BEASTALITY", "BEHAVIORAL", "BENEFICIAL", "BESTIALITY", "BIOLOGICAL", "BIRMINGHAM", "BLACKBERRY", "BOUNDARIES", "BRITANNICA", "BURLINGTON", "BUSINESSES", "CALCULATED", "CALCULATOR", "CALIFORNIA", "CAMCORDERS", "CANDIDATES", "CAPABILITY", "CARTRIDGES", "CATEGORIES", "CHALLENGED", "CHALLENGES", "CHANCELLOR", "CHARACTERS", "CHARITABLE", "CHARLESTON", "CHRISTIANS", "CHRONICLES", "CIGARETTES", "CINCINNATI", "CITYSEARCH", "CLASSIFIED", "COLLEAGUES", "COLLECTING", "COLLECTION", "COLLECTIVE", "COLLECTORS", "COLUMNISTS", "COMMENTARY", "COMMERCIAL", "COMMISSION", "COMMITMENT", "COMMITTEES", "COMPARABLE", "COMPARISON", "COMPATIBLE", "COMPLAINTS", "COMPLEMENT", "COMPLETELY", "COMPLETING", "COMPLETION", "COMPLEXITY", "COMPLIANCE", "COMPONENTS", "COMPRESSED", "COMPROMISE", "CONCEPTUAL", "CONCERNING", "CONCLUSION", "CONDITIONS", "CONDUCTING", "CONFERENCE", "CONFIDENCE", "CONFIGURED", "CONNECTING", "CONNECTION", "CONNECTORS", "CONSIDERED", "CONSISTENT", "CONSISTING", "CONSORTIUM", "CONSPIRACY", "CONSTANTLY", "CONSTITUTE", "CONSTRAINT", "CONSULTANT", "CONSULTING", "CONTACTING", "CONTAINERS", "CONTAINING", "CONTINUING", "CONTINUITY", "CONTINUOUS", "CONTRACTOR", "CONTRIBUTE", "CONTROLLED", "CONTROLLER", "CONVENIENT", "CONVENTION", "CONVERSION", "CONVICTION", "COORDINATE", "COPYRIGHTS", "CORRECTION", "CORRUPTION", "COUNSELING", "CREATIVITY", "CUMULATIVE", "CURRENCIES", "CURRICULUM", "CUSTOMIZED", "DECORATING", "DECORATIVE", "DEFINITELY", "DEFINITION", "DELEGATION", "DELIVERING", "DEMOCRATIC", "DEPARTMENT", "DEPENDENCE", "DEPLOYMENT", "DEPRESSION", "DESCENDING", "DESCRIBING", "DESIGNATED", "DETERMINED", "DETERMINES", "DEVELOPERS", "DEVELOPING", "DIAGNOSTIC", "DICTIONARY", "DIFFERENCE", "DIFFICULTY", "DIMENSIONS", "DIRECTIONS", "DISABILITY", "DISCIPLINE", "DISCLAIMER", "DISCLOSURE", "DISCOUNTED", "DISCOVERED", "DISCRETION", "DISCUSSING", "DISCUSSION", "DISPATCHED", "DISPLAYING", "DISTRIBUTE", "DOCUMENTED", "DOWNLOADED", "EARTHQUAKE", "ECOLOGICAL", "EDITORIALS", "EFFICIENCY", "ELECTRICAL", "ELECTRONIC", "ELEMENTARY", "EMPLOYMENT", "ENCOURAGED", "ENCOURAGES", "ENCRYPTION", "ENDANGERED", "ENGAGEMENT", "ENROLLMENT", "ENTERPRISE", "EQUIVALENT", "ESPECIALLY", "ESSENTIALS", "ESTIMATION", "EVALUATING", "EVALUATION", "EVENTUALLY", "EVERYTHING", "EVERYWHERE", "EXCELLENCE", "EXCEPTIONS", "EXCITEMENT", "EXECUTIVES", "EXHIBITION", "EXPERIENCE", "EXPERIMENT", "EXPIRATION", "EXPLAINING", "EXPLICITLY", "EXPRESSION", "EXTENSIONS", "EXTRACTION", "FACILITATE", "FACILITIES", "FAVOURITES", "FEDERATION", "FELLOWSHIP", "FORMATTING", "FORWARDING", "FOUNDATION", "FRAGRANCES", "FREQUENTLY", "FRIENDSHIP", "FUNCTIONAL", "GENERATING", "GENERATION", "GENERATORS", "GEOGRAPHIC", "GEOLOGICAL", "GIRLFRIEND", "GOVERNANCE", "GOVERNMENT", "GRADUATION", "GREENHOUSE", "GREENSBORO", "GUARANTEED", "GUARANTEES", "GUIDELINES", "HARASSMENT", "HEADPHONES", "HEALTHCARE", "HELICOPTER", "HIGHLIGHTS", "HISTORICAL", "HORIZONTAL", "HOUSEHOLDS", "HOUSEWARES", "HOUSEWIVES", "HUMANITIES", "HUNTINGTON", "HYPOTHESIS", "IDENTIFIED", "IDENTIFIER", "IDENTIFIES", "IMMIGRANTS", "IMMUNOLOGY", "IMPORTANCE", "IMPOSSIBLE", "IMPRESSION", "IMPRESSIVE", "INCENTIVES", "INCOMPLETE", "INCREASING", "INCREDIBLE", "INDICATING", "INDICATION", "INDICATORS", "INDIGENOUS", "INDIVIDUAL", "INDONESIAN", "INDUSTRIAL", "INDUSTRIES", "INFECTIONS", "INFECTIOUS", "INFLUENCED", "INFLUENCES", "INITIATIVE", "INNOVATION", "INNOVATIVE", "INSPECTION", "INSTALLING", "INSTITUTES", "INSTRUCTOR", "INSTRUMENT", "INSULATION", "INTEGRATED", "INTERESTED", "INTERFACES", "INTERNSHIP", "INTERSTATE", "INTERVIEWS", "INTRODUCED", "INTRODUCES", "INVESTMENT", "INVITATION", "IRRIGATION", "JAVASCRIPT", "JOURNALISM", "JOURNALIST", "KAZAKHSTAN", "KILOMETERS", "LABORATORY", "LANDSCAPES", "LAUDERDALE", "LEADERSHIP", "LEGITIMATE", "LIKELIHOOD", "LIMITATION", "LIMOUSINES", "LITERATURE", "LITIGATION", "LOUISVILLE", "LUXEMBOURG", "MACROMEDIA", "MADAGASCAR", "MAINSTREAM", "MAINTAINED", "MANAGEMENT", "MANCHESTER", "MASTERCARD", "MEANINGFUL", "MECHANICAL", "MECHANISMS", "MEDICATION", "MEDITATION", "MEMBERSHIP", "METABOLISM", "MICROPHONE", "MILFHUNTER", "MILLENNIUM", "MINISTRIES", "MITSUBISHI", "MODERATORS", "MONITORING", "MONTGOMERY", "MOTIVATION", "MOTORCYCLE", "MOZAMBIQUE", "MULTIMEDIA", "MYSTERIOUS", "NATIONALLY", "NATIONWIDE", "NAVIGATION", "NETWORKING", "NEWSLETTER", "NEWSPAPERS", "NOMINATION", "NOTTINGHAM", "OBITUARIES", "OBJECTIVES", "OBLIGATION", "OCCASIONAL", "OCCUPATION", "OCCURRENCE", "OFFICIALLY", "OPERATIONS", "OPPOSITION", "ORGANIZING", "ORIGINALLY", "PAPERBACKS", "PARAGRAPHS", "PARAMETERS", "PARLIAMENT", "PARTICULAR", "PASSENGERS", "PERCENTAGE", "PERCEPTION", "PERFORMING", "PERIPHERAL", "PERMISSION", "PERSISTENT", "PERSONALLY", "PETERSBURG", "PHARMACIES", "PHENOMENON", "PHILOSOPHY", "PHOTOGRAPH", "PHYSICALLY", "PHYSICIANS", "PHYSIOLOGY", "PITTSBURGH", "POLYPHONIC", "POPULARITY", "POPULATION", "PORTSMOUTH", "PORTUGUESE", "POSSESSION", "POSTPOSTED", "POWERPOINT", "PREDICTION", "PREFERENCE", "PRESCRIBED", "PRESENTING", "PREVENTING", "PREVENTION", "PREVIOUSLY", "PRINCIPLES", "PRIORITIES", "PRIVILEGES", "PROCEDURES", "PROCEEDING", "PROCESSING", "PROCESSORS", "PRODUCTION", "PRODUCTIVE", "PROFESSION", "PROGRAMMER", "PROGRAMMES", "PROHIBITED", "PROJECTION", "PROJECTORS", "PROMOTIONS", "PROPERTIES", "PROPORTION", "PROTECTING", "PROTECTION", "PROTECTIVE", "PROVIDENCE", "PROVINCIAL", "PROVISIONS", "PSYCHIATRY", "PSYCHOLOGY", "PUBLISHERS", "PUBLISHING", "PUNISHMENT", "PURCHASING", "QUALIFYING", "QUANTITIES", "QUEENSLAND", "QUOTATIONS", "REASONABLE", "REASONABLY", "RECIPIENTS", "RECOGNISED", "RECOGNIZED", "RECOMMENDS", "RECORDINGS", "RECREATION", "RECRUITING", "REDUCTIONS", "REFERENCED", "REFERENCES", "REFLECTION", "REGARDLESS", "REGISTERED", "REGRESSION", "REGULATION", "REGULATORY", "RELATIVELY", "RELAXATION", "RELOCATION", "REMARKABLE", "REMEMBERED", "REPOSITORY", "REPRESENTS", "REPRODUCED", "REPUBLICAN", "REPUTATION", "REQUESTING", "RESEARCHER", "RESISTANCE", "RESOLUTION", "RESPECTIVE", "RESPONDENT", "RESPONDING", "RESTAURANT", "RESTRICTED", "RETIREMENT", "REVELATION", "REVOLUTION", "RICHARDSON", "SACRAMENTO", "SCHEDULING", "SCIENTIFIC", "SCIENTISTS", "SCREENSHOT", "SECURITIES", "SELECTIONS", "SEPARATELY", "SEPARATION", "SETTLEMENT", "SIGNATURES", "SIMPLIFIED", "SIMULATION", "SITUATIONS", "SOUNDTRACK", "SPECIALIST", "STATEMENTS", "STATIONERY", "STATISTICS", "STRATEGIES", "STRENGTHEN", "STRUCTURAL", "STRUCTURED", "STRUCTURES", "SUBJECTIVE", "SUBMISSION", "SUBMITTING", "SUBSCRIBER", "SUBSECTION", "SUBSEQUENT", "SUBSIDIARY", "SUBSTANCES", "SUBSTITUTE", "SUCCESSFUL", "SUFFICIENT", "SUGGESTING", "SUGGESTION", "SUNGLASSES", "SUPERVISOR", "SUPPLEMENT", "SUPPORTERS", "SUPPORTING", "SURPRISING", "SURROUNDED", "SUSPENSION", "SYSTEMATIC", "TECHNICIAN", "TECHNIQUES", "TECHNOLOGY", "TELEVISION", "TERRORISTS", "THEMSELVES", "THEREAFTER", "THOROUGHLY", "THREATENED", "THROUGHOUT", "THUMBNAILS", "THUMBZILLA", "TOURNAMENT", "TRACKBACKS", "TRADEMARKS", "TRADITIONS", "TRANSCRIPT", "TRANSEXUAL", "TRANSITION", "TRANSLATED", "TRANSLATOR", "TRAVELLING", "TREATMENTS", "TREMENDOUS", "ULTIMATELY", "UNDERLYING", "UNDERSTAND", "UNDERSTOOD", "UNDERTAKEN", "UNEXPECTED", "UNIVERSITY", "UZBEKISTAN", "VALIDATION", "VARIATIONS", "VEGETABLES", "VEGETARIAN", "VEGETATION", "VETERINARY", "VIETNAMESE", "VIOLATIONS", "VISIBILITY", "VOCABULARY", "VOCATIONAL", "VOLKSWAGEN", "VOLLEYBALL", "VOLUNTEERS", "VULNERABLE", "WALLPAPERS", "WARRANTIES", "WASHINGTON", "WATERPROOF", "WEBMASTERS", "WELLINGTON", "WIDESCREEN", "WIDESPREAD", "WILDERNESS", "WITHDRAWAL", "YUGOSLAVIA"]

It works for other lengths too, but I thought I'd specifically mention the ones within the spec that it will indeed work for. For example 227 results in:

["ABS", "BAR", "BBS", "CAP", "CAR", "CAS", "CBS"]

If the winner of this challenge is being chosen by shortest code, I can make this 140 bytes shorter if needed.

\$\endgroup\$
  • \$\begingroup\$ Cool, that's better :D \$\endgroup\$ – Jonathan Allan Apr 1 at 18:17
  • 1
    \$\begingroup\$ @JonathanAllan "Yugoslavia" is a better example word anyway :). \$\endgroup\$ – Magic Octopus Urn Apr 1 at 18:19
  • \$\begingroup\$ Oh, 227 should not result in any words - again point (4) - "Strip all non-numerical characters and make sure what’s left is a seven or ten-digit integer." - not sure what this means for leading zeros. \$\endgroup\$ – Jonathan Allan Apr 1 at 18:21
  • 1
    \$\begingroup\$ @JonathanAllan fixed as well. \$\endgroup\$ – Magic Octopus Urn Apr 1 at 18:30
  • 1
    \$\begingroup\$ Using A…!!ÿ•eŒi•5в£€S as keypad letters and lower-case saves 27 bytes. \$\endgroup\$ – Emigna Apr 1 at 19:23
2
\$\begingroup\$

C# (Visual C# Interactive Compiler), 217 bytes

n=>n.Where(c=>c>47&c<58).Select(c=>", , abc def ghi jkl mno pqrs tuv wxyz".Split()[c-48]).Aggregate(new[]{""},(a,b)=>a.SelectMany(c=>b.Select(d=>c+d)).ToArray()).Where(x=>File.ReadAllText("a.txt").Contains($@"
{x}
"))

Expects the dictionary in a file named a.txt.

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Why not just store it in a file called "a"? \$\endgroup\$ – Expired Data Apr 1 at 16:59
  • \$\begingroup\$ @ExpiredData Not enough storage xD \$\endgroup\$ – Embodiment of Ignorance Apr 1 at 17:02
  • \$\begingroup\$ No I mean... 213 bytes \$\endgroup\$ – Expired Data Apr 1 at 17:09
  • \$\begingroup\$ Does this deal with (4) from the question (throwing away non digit characters and only returning any results if there are exactly 10 or 7 digits)? \$\endgroup\$ – Jonathan Allan Apr 1 at 18:07
  • \$\begingroup\$ @JonathanAllan See the where statement in the beginning? \$\endgroup\$ – Embodiment of Ignorance Apr 1 at 18:25
2
\$\begingroup\$

VDM-SL, 313 395 385 289 278 bytes

f(i)==let m={'2'|->"abc",'3'|->"def",'4'|->"ghi",'5'|->"jkl",'6'|->"mno",'7'|->"pqrs",'8'|->"tuv",'9'|->"wxyz"},d=IO`freadval[set of ?],q=[i(p)|p in set inds i&i(p) in set dom m]in let r in set d("f").#2 be st forall x in set inds q&len(q)=len(r)and r(x)in set elems m(q(x))in r

Turns out IO is easier than I thought!

Still expensive because of building the map (I'm sure there'll be a good map comprehension for it I've just not thought of it yet) and could save further bytes if the string was guaranteed to only contain values in the domain of the map

Explanation:

f(i)==
let m=...,                           /* m is a map of char to seq of char */
d=IO`freadval[set of ?]            /* d is the file read function that will read a set of something */ 
q=[i(p)|p in set inds i&i(p) in set dom m] /* q is a sequence comprehension defined by 
                                             take the values in i where i is in the domain 
                                             of our map m */
let r in set d("f").#2                    /* let r be a value in my dictionary of words (read from the file f) */ 
be st                                     /* such that */ 
forall x in set inds q&len(q)=len(r)      /* the length of q and r are the same */
and r(x)in set elems m(q(x))              /* for every char in q the char in 
                                                  r at that position is in the range of the 
                                                  map for that char in q */
in r         /* return r*/
\$\endgroup\$
  • \$\begingroup\$ This language is new to me; what answers do you get for 323 454-6503 and 868-454-6523? \$\endgroup\$ – Michael Stern Apr 1 at 16:09
  • \$\begingroup\$ I'll post an explanation soon. Surely answers are dependent on the dictionary? \$\endgroup\$ – Expired Data Apr 1 at 16:11
  • \$\begingroup\$ Yes, any comprehensive answer depends on the dictionary used but I have no way to test your code except by asking for representative output. There are some answers that are going to appear for any reasonable dictionary, and if the code produces words that couldn’t emerge from these numbers then we know there’s a problem. \$\endgroup\$ – Michael Stern Apr 1 at 16:15
  • \$\begingroup\$ @MichaelStern It will take a long time to terminate for those inputs with a none toy dictionary, since it scans every value in the dictionary to test whether it is a valid fit for all characters in the input. It'd be better if you gave test cases as valid/invalid so I can construct a dictionary of the valid and invalid and show it gives correct values for each \$\endgroup\$ – Expired Data Apr 1 at 16:31
  • \$\begingroup\$ Does this deal with (4) from the question (throwing away non digit characters and only returning any results if there are exactly 10 or 7 digits)? \$\endgroup\$ – Jonathan Allan Apr 1 at 18:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.