, Website of Satan

Michael Hoffman at mh391.invalid
Fri Jan 14 12:16:59 CET 2005

Peter Renzland wrote:
> What is the simplest/fastest Python program to determine how many
> IP addresses sum up to 666?
> The simplest/fastest enumerator?
> The simplest/fastest that determines which ones of them are home pages?

This seems to work although it could be made more efficient or elegant. 
Also, the failed gethostbyaddr() calls take forever.

from socket import gethostbyaddr, herror

for a in xrange(256):
     if a < 666-255*3:
     for b in xrange(256):
         if a+b < 666-255*2:
         for c in xrange(256):
             if a+b+c < 666-255:
             for d in xrange(256):
                 if a + b + c + d == 666:
                     ip_address = "%d.%d.%d.%d" % (a, b, c, d)
                         hostname, aliaslist, ipaddrlist = 
                     except herror:
                         hostname = "NONE"
                     print hostname, ip_address
Michael Hoffman

More information about the Python-list mailing list