#!/usr/bin/perl -w # I decided to start playing JigWords the other day # (http://games.yahoo.com/games/downloads/jigwords.html) # but then I got bored and decided to write a script to help play the game. # It'll generally work for any kind of word jumble. # It performs two dictionary searches, one of the words definitely in use, and # one of the standard system dictionary. :) # # By: Theo Van Dinter (c) 2006 use strict; $|++; my %max = (); my $letters = shift; my $RE = qr/^[$letters]{3,6}$/i; foreach(split(//,$letters)) { $max{$_}++; } my @words = (); while () { chomp; push(@words, $_) if check_word($_); }; @words = sort { length $a <=> length $b } @words; print join("\n", @words, "", ""); @words = (); @ARGV = qw{ /usr/share/dict/words } unless @ARGV; while (<>) { chomp; tr/A-Z/a-z/; push(@words, $_) if check_word($_); }; @words = sort { length $a <=> length $b } @words; print join("\n", @words, ""); { my %seen = (); sub check_word { my $word = $_[0]; return unless $word =~ /$RE/; return if $seen{$word}++; my %count = (); foreach (split(//,$word)) { $count{$_}++; if ($count{$_} > $max{$_}) { %count = (); last; } } return %count; } } __DATA__ abet able ably abs acing act acting add adhere admen age aged ago air alas album albums ale all alp alps also alto altos alum alums amen amend amp amps and angel angle ant ante anti antic ape aped arc arcing arcs are area argon ark arks ask asp ate aye bad bade badly bake baked bald bale balm balms bam ban band bane baned bank banked bar bard bat bate battle bay bead beak bean beat bed beds beg begs belt bend berth besot best bet beta bets bid bide bird bisect bit bite bites bits bleat bore both bother bout bouts bra bray bred bride brie broth bud budge budges buds bug bugs bum bums buried bus bused bust but cairn can cans cant car caring cars cask cat chide chin chine chines chins chits cigar cite cited cites cod code coed come comes comet comets cop cope coped cost cot cotes cots coup coupe couped crank cranks cud cuds cue cued cues cup dab dad dagger dam dame dank dare darn day dead dean dear debug debugs deck deco deer deli delve demand den dens dent devil dice die diet dike dim dime dimer dire ditch dive doe doer dole door dope dopy dory dot dote doter drab drably drag drape drop drops dropsy drug drupe dry dub dubs due duel dues duet duets dug dunce dunces dune dunes dung duo dupe duper dust ear eared earl earn earned eat edict edit eel egad egg ego elf elide emu emus end endear ends eon era err etch ethic eve evil fan fang fed fir fire fired firm firmed flag flan flange flea fried gad gag gage gaged gain gait gal gale gear gel geld genius genus get gets getup getups giant gilt gin gins glean glen glint glue glued gluon glut gnat gnu gnus gone grad grade grain grin groan groin guest guilt guise gulden gun guns gust gut guts had hard hare hared head header hear heard heed heir heirs hen hens hep her herb herd here hero hers hew hid hide hint hints hire hires his hit hits hoe hoer hole hot how howl howler hue hues ice iced ices idem idle ill ills inch inches ink inks inn inns ins ion ire iron isle itch itched its kid kin kine kit kite kited knead kolas lab labs lad lady lag lamas lamb lambs lamp lamps lane lap laps lard lardy last late latent latte lay lea leaf lean leant learn led lee leg lei leis lend lent let levied lid lie lied lies lilt lilts lint lire list lit live lived lode log loge lone long loop looped lop lope loped lops lord lords lore lost lot lots lounge low lower lows lug lunar lung lunge lunged lure luting mad madden made man mane maned map maps maul mauls mead mean men mend met mid mire mired morn morns most mote motes mourn mourns mud muons muse mused must musted mute muted mutes nab nag naked name named narc narcs narks near neared neat neck necks need nerd net neural nice niche niches nick nicks nil ninth ninths nit nits noel nor norm norms not nude nudes nudge nut nuts oak oaks oar oaring oat oats obtuse ode odor ogle old ole oleo one onus opal opals opt orb ore organ other otter our ours oust ousts out outs owe owl owls pad padre pal palm palms pals par parade pare pared pas pea pear peg pegs pen pend pent per pert pest pet pets plasm plasma pled plod pod pods poet pole poled polka polkas polo poodle pool pooled pore port porter posy pot pro prod prods pros prosy prude pry psalm puce pug pugs pun punt punted pure pured purge purged purse push pusher put puts racing rack racks rad rag rage raged ragged rain ran ranee rang rank ranks rap ray read real reap rebid red redo reed ref relish renal rep report reps retro rhesus rib rid ride rife rig rile riles rim rime rimed ring rise roan rob robe rod rode rodeo rods role root rooted rope roper rosy rot rote roted rots rotted row rowel rows rub rube rubied rude rue rued rues rug rule rum rums run runs ruse ruses rush rushes sack salt sank sap sat scan scar scud sea seal sect send set setup she shes shier shin shine shire sic sick sicken sign sill silt sin since sine sing singe sink sir sire sit site skein ski skin skoal slab slam slap slat slier slit slop slot slow slum smote smut snack snick snit snitch snot snots snout snouts snug soak soap sob sod sold some son sons sort sorts sot sots sour sow sows soy spa spry spur spy stat stem step still stoat stow stows stub stud stun stuns sub sue sued sues suing sum sumo sun sung suns super sure swill sword tab table tablet tag tale talent tan tang tea teal tech ten tend tent the thin thins this throb throe tic tick ticked ticketd tics tide tie tied ties tike till tills tin ting tins toast toe toes tom tome tomes toms ton tons too top tore tort torte toss tost tot total totals tote toted tots tow tows trod trope trot trow trows tub tube tubes tubs tug tugs tune tuned twill twills two twos ulnae ulnar unit unlit unreal until unto upend ups upset urge urged urn urns use used user users uses usher ushers using veil veiled vie vied vile war wars who whole whorl will wills wilt wilts wit wits woe wold wolds word words wore world worlds worst worsts worts yard