Oof.

(Thanks.) :-}

Proving once again that eyeballing the test is not running the test!

As penance I have reduced it from seven lines to six. This one is actually
tested.

########
import sys

concord = {}
for word in [token.lower() for token in open(sys.argv
[1],"r").read().split()]:
  concord[word] = concord.get(word,0) + 1
result = sorted(concord.items(), lambda x,y: cmp(-x[1],-y[1]) or
cmp(x[0],y[0]) )
print "\n".join( ["%s\t%s" % pair[-1::-1] for pair in result] )

# mt
########


On 3/26/07, Toby Donaldson <[EMAIL PROTECTED]> wrote:

Actually, it appears your code makes a common error: according to the
problem specification, when frequencies are tied, they should be
ordered alphabetically.
_______________________________________________
Edu-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/edu-sig

Reply via email to