Advertisement
Guest User

Solution

a guest
Apr 27th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. import random
  2. import enchant
  3.  
  4. row_data = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm']
  5. row_choices_used = []
  6. row_choice = random.choice(range(0, len(row_data)))
  7. data = ''
  8. data_list = []
  9. d = enchant.Dict('en_US')
  10. count = 0
  11. possibility_count = 0
  12.  
  13. while possibility_count < 3780:
  14.    while count < len(row_data):
  15.       while row_choice in row_choices_used:
  16.          row_choice = random.choice(range(0, len(row_data)))
  17.       row_choices_used.append(row_choice)
  18.       the_choice = random.choice(row_data[row_choice])
  19.       data += the_choice
  20.       count += 1
  21.    if data not in data_list:
  22.      data_list.append(data)
  23.      possibility_count += 1
  24.    row_choices_used = []
  25.    data = ''
  26.    count = 0
  27.  
  28. f = open("data.txt", "w")
  29. useless_words = 0 # Just for reference
  30. useful_words = 0 # Also for reference
  31. for word in data_list:
  32.    if d.check(word) == True:
  33.       f.write(word + '\n')
  34.       useful_words += 1
  35.    else:
  36.       useless_words += 1
  37.  
  38. f.close()
  39. print("Number of English words :", str(useful_words))
  40. print("Number of random words :", str(useless_words))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement