On Sat, 10 May 2008 18:06:17 +1000, Arnaud Delobelle
<[EMAIL PROTECTED]> wrote:
"Kam-Hung Soh" <[EMAIL PROTECTED]> writes:
On Sat, 10 May 2008 07:19:38 +1000, <[EMAIL PROTECTED]> wrote:
> What would be the best method to print the top results, the one's
that
> had the highest amount of a
"Kam-Hung Soh" <[EMAIL PROTECTED]> writes:
> On Sat, 10 May 2008 07:19:38 +1000, <[EMAIL PROTECTED]> wrote:
>
>>> > What would be the best method to print the top results, the one's that
>>> > had the highest amount of anagrams?? Create a new histogram dict?
>>>
>>> You can use the max() function
On May 9, 11:19 pm, dave <[EMAIL PROTECTED]> wrote:
> On 2008-05-09 18:53:19 -0600, George Sakkis <[EMAIL PROTECTED]> said:
>
>
>
> > On May 9, 5:19 pm, [EMAIL PROTECTED] wrote:
> What would be the best method to print the top results, the one's that
>
> had the highest amount of anagrams
On 2008-05-09 18:53:19 -0600, George Sakkis <[EMAIL PROTECTED]> said:
On May 9, 5:19 pm, [EMAIL PROTECTED] wrote:
What would be the best method to print the top results, the one's that
had the highest amount of anagrams?? Create a new histogram dict?
You can use the max() function to fin
On May 9, 5:19 pm, [EMAIL PROTECTED] wrote:
> > > What would be the best method to print the top results, the one's that
> > > had the highest amount of anagrams?? Create a new histogram dict?
>
> > You can use the max() function to find the biggest list of anagrams:
>
> > top_results = max(anagra
On Sat, 10 May 2008 07:19:38 +1000, <[EMAIL PROTECTED]> wrote:
> What would be the best method to print the top results, the one's that
> had the highest amount of anagrams?? Create a new histogram dict?
You can use the max() function to find the biggest list of anagrams:
top_results = max(an
> > What would be the best method to print the top results, the one's that
> > had the highest amount of anagrams?? Create a new histogram dict?
>
> You can use the max() function to find the biggest list of anagrams:
>
> top_results = max(anagrams.itervalues(), key=len)
>
> --
> Arnaud
That is t
[EMAIL PROTECTED] writes:
> On May 9, 1:45 am, [EMAIL PROTECTED] wrote:
>> >>> key = ''.join(sorted(word))
>>
>> I tend to strip and lower the word as well, otherwise "Hello" and
>> "hello" do not compare...depends on what you want though!
>> Plus you might get a lot of "word\n" as keys...
>>
>> M
On May 9, 1:45 am, [EMAIL PROTECTED] wrote:
> >>> key = ''.join(sorted(word))
>
> I tend to strip and lower the word as well, otherwise "Hello" and
> "hello" do not compare...depends on what you want though!
> Plus you might get a lot of "word\n" as keys...
>
> My technique is the this way
>
> def
>>> key = ''.join(sorted(word))
I tend to strip and lower the word as well, otherwise "Hello" and
"hello" do not compare...depends on what you want though!
Plus you might get a lot of "word\n" as keys...
My technique is the this way
def anagram_finder(words):
anagrams = {}
for word in wo
"Kam-Hung Soh" <[EMAIL PROTECTED]> writes:
> I avoid creating a temporary variable if it's only used once
> immediately, so I would have written:
>
> newtlist = ''.join(sorted(list(line)))
Or ''.join(sorted(line))
as sorted() works with any iterable.
--
Arnaud
--
http://mail.python.org/mailma
On Thu, May 8, 2008 at 7:52 PM, dave <[EMAIL PROTECTED]> wrote:
> I got it! Thanks for all your help!!! Please tell me what you think:
Here's yet another version of the same thing, using defaultdicts and
sets. This way we don't have to test for membership in either the
dictionary or the co
On Fri, 09 May 2008 09:52:53 +1000, dave <[EMAIL PROTECTED]>
wrote:
I got it! Thanks for all your help!!! Please tell me what you think:
def anafind():
fin = open('short.txt') #one word per line
mapdic = {} #this di
dave <[EMAIL PROTECTED]> writes:
> if newtlist not in mapdic:
> mapdic[newtlist] = [line]
> if line not in mapdic[newtlist]:
> mapdic[newtlist].append(line)
I'd use the defaultdi
On 2008-05-07 19:25:53 -0600, "Kam-Hung Soh" <[EMAIL PROTECTED]>
said:
On Thu, 08 May 2008 11:02:12 +1000, dave <[EMAIL PROTECTED]
t>
wrote:
Hi All,
I wrote a program that takes a string sequence and finds all the wo
rds
inside a text file (one word per line) and prints them:
def an
Been there, done that:
http://polyglot-anagrams.googlecode.com/svn/trunk/python/
--
http://mail.python.org/mailman/listinfo/python-list
"Kam-Hung Soh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| On Thu, 08 May 2008 15:42:07 +1000, dave <[EMAIL PROTECTED]>
| wrote:
| Your code is always going to return the same list because every word is
an
| anagram of itself.
|
| Tip: Create a list for each dictionary key, the
On Thu, 08 May 2008 15:42:07 +1000, dave <[EMAIL PROTECTED]>
wrote:
This is what i've came up with. My problem is that I can't get them to
properly evaluate.. when comparewords() runs it finds itself... Should
I have the keys of mapdict iterate over itself? Is that possible?
def annaf
This is what i've came up with. My problem is that I can't get them to
properly evaluate.. when comparewords() runs it finds itself...
Should I have the keys of mapdict iterate over itself? Is that
possible?
def annafind():
fin = open('text.txt') # file has one word per li
On Thu, 08 May 2008 11:02:12 +1000, dave <[EMAIL PROTECTED]>
wrote:
Hi All,
I wrote a program that takes a string sequence and finds all the words
inside a text file (one word per line) and prints them:
def anagfind(letters): #find anagrams of these letters
fin = open('text.txt')
Hi All,
I wrote a program that takes a string sequence and finds all the words
inside a text file (one word per line) and prints them:
def anagfind(letters): #find anagrams of these letters
fin = open('text.txt') #one word per line file
wordbox = [] #this is where
21 matches
Mail list logo