What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » General » General Chit Chat » Request: word list(s)

Request: word list(s)
Author: Message:
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
RE: Request: word list(s)
there is a difference between jumbling and anagraming
the other day i wrote some python to solve the 9 letter word from the target in the SMH
you can also use a similar principle to find real anagrams

python code:
from __future__ import with_statement
def ret_words(letter,words):
    return [item for item in words if letter in item]
ana=raw_input("jumble: ")
with open("words-english.dic",'r') as dic:
    x = set([item for item in [line.strip("\r\n") for line in dic.readlines()] if len(item)==len(ana)])#this only targets words of the right length
a = list(ana)
while a:#this targets words containing the same characters
    x = ret_words(a.pop(),x)
a=sorted(ana)
for item in x:#this matches letter patterns to check if it is in fact an anagram
    if a == sorted(list(item)):
        print item
####################that was the conceptual python

##this is the engineered python
i=raw_input('j: ')
#now the line above and either of the following lines
for item in filter((lambda x: sorted(x) == sorted(i)),[ line.strip("\r\n") for line in open("words-english.dic","r").readlines() if len(line.strip('\r\n'))==len(i)]):print item
#the other solution
for item in [item for item in[line.strip("\r\n") for line in open("words-english.dic","r").readlines() if len(line.strip('\r\n'))==len(i)] if sorted(item)==sorted(i)]:print item

using those filtering principles you should be able to write something to produce anagrams, but if you are trying to jumble words, you could use the code I wrote to generate test cases for my code above
python code:
import random
def shuffled(x):
    random.shuffle(x)
    return x
print "".join(shuffled(list(raw_input("String to jumble: "))))

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














07-07-2009 06:32 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Request: word list(s) - by SmokingCookie on 07-06-2009 at 02:37 PM
RE: Request: word list(s) - by Menthix on 07-06-2009 at 02:44 PM
RE: Request: word list(s) - by SmokingCookie on 07-06-2009 at 02:47 PM
RE: Request: word list(s) - by djdannyp on 07-06-2009 at 02:50 PM
RE: RE: Request: word list(s) - by SmokingCookie on 07-06-2009 at 02:52 PM
RE: Request: word list(s) - by djdannyp on 07-07-2009 at 06:11 AM
RE: RE: Request: word list(s) - by SmokingCookie on 07-07-2009 at 08:21 AM
RE: Request: word list(s) - by Jarrod on 07-07-2009 at 06:32 AM
RE: Request: word list(s) - by Jarrod on 07-07-2009 at 08:38 AM
RE: Request: word list(s) - by SmokingCookie on 07-07-2009 at 08:41 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On