Created
February 16, 2017 17:01
-
-
Save leigh-johnson/481b51172f49053b6cbcb5734c4a4f8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
import requests | |
import time | |
def capitalizations(str): | |
'''Return a list of the different ways of capitalizing the letters in | |
string str. | |
>>> capitalizations('dog') | |
['DOG', 'DOg', 'DoG', 'Dog', 'dOG', 'dOg', 'doG', 'dog'] | |
>>> capitalizations('a1b2') | |
['A1B2', 'A1b2', 'a1B2', 'a1b2'] | |
''' | |
return map(''.join, product(*( set((char.upper(), char.lower())) | |
for char in str))) | |
# >>> print len(capitalizations('nocsr1wj')) | |
# 128 | |
for slug in capitalizations('nocsr1wj'): | |
r = requests.get('http://pastebin.com/' + slug) | |
if r.status_code != 404: | |
print 'SUCCESS http://pastebin.com/' + slug | |
else: | |
print r.status_code, 'http://pastebin.com/' + slug | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment