[PyAR2] Car Talk Puzzler (The Hall of Lights)

Wayne Werner waynejwerner at gmail.com
Thu Nov 3 19:43:02 CET 2011

On Thu, Nov 3, 2011 at 1:17 PM, Chris Nestrud <ccn at panix.com> wrote:

> #Begin
> from math import sqrt
> max_lights = 20000
> print("Lights on: %s" % (', '.join((str(l*l) for l in
> xrange(1,int(sqrt(max_lights)+1),1)))))
> #End
You can actually  do this one (or two lines...) better:
print("Lights on: %s" % (', '.join((str(i) for i in range(1, 20001) if

Or if you're really going for terse:
[print(i) for i in range(1,20001) if i**.5%1==0.0]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/pyar2/attachments/20111103/103a9a12/attachment.html>

More information about the PyAR2 mailing list