On Tue, 20 Jan 2009 09:20:22 -0800, Marc Tompkins wrote: > On Tue, Jan 20, 2009 at 5:42 AM, Lie Ryan <lie.1...@gmail.com> wrote: > >> > Using sys.maxint to prime minLen is overkill, of course - >> > "antidisestablishmentarianism" is only 28 letters long, after all - >> > but it should be larger than any word you can expect to see. This >> > doesn't catch ties, though... could do that like so: > >> Other than overkill, it is wrong. If the shortest "word" is longer than >> maxint it'd give wrong result. > > What language do you speak (or machine do you use), where the shortest > word in a potential list is longer than maxint? On my machine maxint is > 2,147,483,647. That's what I meant by overkill.
what I meant as wrong is that it is possible that the code would be used for a string that doesn't represent human language, but arbitrary array of bytes. Also, it is a potential security issue. > You could just simply use the len of the first word. > > True dat. Requires an extra step or two, though - initializing with > some impossibly huge number is quick. len() is fast, and it also removes the need to import sys, which actually removes an extra step or two >> The best solution though, have been answered by Kent Johnson. >> > Extremely terse and elegant, doesn't find ties. <snip> > Output: No which, at the time of writing, was my impression on the OP's request. > Mine returns (2, ['No', 'is'], 9, ['repressed', 'alienated']). I could > be wrong - it seemed more like what the OP actually wanted, but he'd be > the judge of that. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor