SimplePrograms challenge
Steve Howell
showell30 at yahoo.com
Tue Jun 12 18:43:32 EDT 2007
--- George Sakkis <george.sakkis at gmail.com> wrote:
>
> from itertools import count, ifilter
> def sieve():
> seq = count(2)
> while True:
> p = seq.next()
> seq = ifilter(p.__rmod__, seq)
> yield p
>
>
> I suspect that it violates your second rule though
> :)
>
I'm genuinely torn. The elegance of the solution far
outweighs its esotericness. And I certainly can't
complain about the choice of the problem (finding
primes), since I included a much more pedestrian
solution to the same problem on the very page that
we're talking about.
I do feel, however, like I want to order solutions by
how long they are in line numbers, and if I stick to
that rule, I do think that the solution above, while
elegant, might be a little advanced as the seventh
example of Python's simplicity.
Is there a way to broaden the problem somehow, so that
it can be a longer solution and further down on the
page, and so that I can continue to enforce my
somewhat arbitrary rule of ordering examples by how
long they are?
(I fully confess that my ordering rule unfairly
penalizes short-and-sweet limitations, but I hope that
*all* solutions are short-and-sweet, and this one
certainly fits the bill.)
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
More information about the Python-list
mailing list