Skip to content

Instantly share code, notes, and snippets.

@amundo
Created July 5, 2013 19:05
Show Gist options
  • Save amundo/5936566 to your computer and use it in GitHub Desktop.
Save amundo/5936566 to your computer and use it in GitHub Desktop.
What .edu sites exist that are anagrams of UCSB?
Desktop/$ ./ping2.py
http://ucsb.edu True
http://ucbs.edu False
http://uscb.edu True
http://usbc.edu False
http://ubcs.edu False
http://ubsc.edu False
http://cusb.edu False
http://cubs.edu False
http://csub.edu True
http://csbu.edu False
http://cbus.edu False
http://cbsu.edu False
http://sucb.edu False
http://subc.edu False
http://scub.edu False
http://scbu.edu True
http://sbuc.edu False
http://sbcu.edu False
http://bucs.edu False
http://busc.edu False
http://bcus.edu False
http://bcsu.edu False
http://bsuc.edu False
http://bscu.edu False
#!/usr/bin/python2.7
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages/')
import requests
import itertools
urls = [''.join(x) for x in list(itertools.permutations(list('ucsb')))]
def ping(host):
try:
res = requests.get(host)
return True
except requests.exceptions.ConnectionError:
return False
for u in urls:
q = 'http://' + u + '.edu'
yesno = str(ping(q))
print( q + '\t' + yesno)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment