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:
continue
for b in xrange(256):
if a+b < 666-255*2:
continue
for c in xrange(256):
if a+b+c < 666-255:
continue
for d in xrange(256):
if a + b + c + d == 666:
ip_address = "%d.%d.%d.%d" % (a, b, c, d)
try:
hostname, aliaslist, ipaddrlist = gethostbyaddr(ip_address)
except herror:
hostname = "NONE"
print hostname, ip_address
break
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to