from transformations import vowel_expand, drop_vowel, l33t, words_with_ck, double_to_single
from wordlist import wordlist
import itertools

ALPHABET = '23456789abcdefghijkmnpqrstuvwxyz'
BLACKLIST = wordlist.words


def main():
    blacklist = set(generate_blacklist(BLACKLIST))
    blacklist_guids = generate_guids(list(blacklist))


def generate_blacklist(blacklist):
    result = []
    result += blacklist
    print('Generating blacklist...')
    n = 0
    total = len(blacklist)
    for word in blacklist:
        print('Processing word {0}/{1}'.format(n, total))
        n += 1
        result += vowel_expand(word, 3)
        result += drop_vowel(word)
        result += words_with_ck(word)
        result += l33t(word)
        result += double_to_single(word)
    return result


def generate_guids(blacklist):
    blacklist_guids = set()
    n = 0
    n_guid = 0
    total = len(blacklist)
    for word in blacklist:
        if 2 < len(word) <= 5:
            n += 1
            print('Processing word {0}/{1}'.format(n, total))
            positions = n_positions(word, 5)
            n_random = 5 - len(word)
            combinations = list(itertools.product(ALPHABET, repeat=n_random))

            for c in combinations:
                for i in range(0, positions):
                    word_list = create_word_list(word, i)
                    available_indices = [i for i, x in enumerate(word_list) if not x]
                    for idx in available_indices:
                        for letter in c:
                            word_list[idx] = letter
                            continue
                    result = ''.join(word_list)
                    blacklist_guids.add(result)
                    print(len(blacklist_guids))
                    n_guid += 1
    return blacklist_guids


def create_word_list(word, index):
    word_list = [None] * 5

    for letter in word:
        word_list[index] = letter
        index += 1
    return word_list


def put(word, guid, i):
    return guid[0:i] + word + guid[len(word) + i:]


def n_positions(word, n):
    return n - len(word) + 1


if __name__ == '__main__':
    main()
@@ -132,16 +132,122 @@
 ertools%0A
+from functools import partial%0Afrom multiprocessing import pool%0Afrom multiprocessing.context import Process
 %0AALPHABE
@@ -378,32 +378,26 @@
 LIST))%0A    b
-lacklist
+ad
 _guids = gen
@@ -397,28 +397,22 @@
 s = 
-generate
+process
 _guids(
-list(
 blac
@@ -417,17 +417,37 @@
 acklist)
-)
+%0A    return bad_guids
 %0A%0A%0Adef g
@@ -557,25 +557,25 @@
 .')%0A    n = 
-0
+1
 %0A    total =
@@ -889,24 +889,208 @@
 rn result%0A%0A%0A
+def get_combinations(length):%0A    combinations = %7B%7D%0A    for x in range(length):%0A        combinations%5Bx + 1%5D = list(itertools.product(ALPHABET, repeat=(x+1)))%0A    return combinations%0A%0A%0A
 def generate
@@ -1092,24 +1092,29 @@
 erate_guids(
+full_
 blacklist):%0A
@@ -1106,24 +1106,38 @@
 ll_blacklist
+, combinations
 ):%0A    black
@@ -1159,49 +1159,77 @@
 t()%0A
+%0A
     
-n = 0%0A    n_guid = 0%0A    total = len(
+if type(full_blacklist) != list:%0A        full_blacklist = %5Bfull_
 blac
@@ -1225,33 +1225,34 @@
  %5Bfull_blacklist
-)
+%5D%0A
 %0A    for word in
@@ -1244,32 +1244,37 @@
     for word in 
+full_
 blacklist:%0A     
@@ -1298,94 +1298,12 @@
 d) %3C
-=
  5:%0A
-            n += 1%0A            print('Processing word %7B0%7D/%7B1%7D'.format(n, total))%0A
     
@@ -1384,87 +1384,8 @@
 rd)%0A
-            combinations = list(itertools.product(ALPHABET, repeat=n_random))%0A%0A
     
@@ -1413,16 +1413,26 @@
 inations
+%5Bn_random%5D
 :%0A      
@@ -1693,29 +1693,45 @@
     
-for letter in c:%0A    
+index = available_indices.index(idx)%0A
     
@@ -1771,51 +1771,16 @@
 %5D = 
-letter%0A                            continue
+c%5Bindex%5D
 %0A   
@@ -1918,16 +1918,24 @@
 t_guids)
+, result
 )%0A      
@@ -1940,58 +1940,430 @@
     
-            n_guid += 1%0A    return blacklist_guids
+elif len(word) == 5:%0A            blacklist_guids.add(word)%0A            print(len(blacklist_guids), word)%0A    return blacklist_guids%0A%0A%0Adef process_guids(data, n=4):%0A    p = pool.Pool(processes=n)%0A    c = get_combinations(2)%0A    map_func = partial(generate_guids, combinations=c)%0A    results = p.map(generate_guids, data)%0A    p.close()%0A%0A    total = set()%0A    for r in results:%0A        total = total.union(r)%0A    return total
 %0A%0A%0Ad
@@ -2528,85 +2528,8 @@
 t%0A%0A%0A
-def put(word, guid, i):%0A    return guid%5B0:i%5D + word + guid%5Blen(word) + i:%5D%0A%0A%0A
 def 
@@ -2614,12 +2614,14 @@
 :%0A    main()
+%0A%0A

Use multiprocessing