Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 10th, 2013  |  syntax: Python  |  size: 1.22 KB  |  views: 177  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. from sys import argv
  2.  
  3. def gen_words(word):
  4.     yield word
  5.     sub = ['aA@', 'bB8', 'cC', 'dD', 'eE3', 'fF', 'gG6', 'hH#', 'iIlL1!', 'jJ', 'kK', 'mM', 'nN', 'oO0', 'pP', 'qQ', 'rR', 'sSzZ5$', 'tT7', 'uUvV', 'wW', 'xX', 'yY']
  6.     def subs(l):
  7.         for i, s in enumerate(sub):
  8.             if l in s:
  9.                 if s.index(l) < len(s) - 1:
  10.                     return s[s.index(l) + 1]
  11.         return l
  12.     def reset_before(word, index):
  13.         new_word = ""
  14.         for i in range(0, index):
  15.             for s in sub:
  16.                 if word[i] in s:
  17.                     new_word += s[0]
  18.             if len(new_word) == i:
  19.                 new_word += word[i]
  20.         return new_word + word[index:]
  21.     index = 0
  22.     while True:
  23.         l = word[index]
  24.         subs_l = subs(l)
  25.         if subs_l != l:
  26.             p1 = "" if index == 0 else word[:index]
  27.             p2 = subs_l
  28.             p3 = "" if index == len(word) else word[index+1:]
  29.             word = p1 + p2 + p3
  30.             word = reset_before(word, index)
  31.             index = 0
  32.             yield word
  33.         else:
  34.             index = index + 1
  35.         if index >= len(word):
  36.             break
  37.  
  38. word = argv[1]
  39. for w in gen_words(word):
  40.     print w
clone this paste RAW Paste Data