uccjshrimpton

Countdown Word Finder

May 13th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.47 KB | None | 0 0
  1. print("Anagram Finder")
  2. print("This program allows you to type in a series of characters and then checks the English dictionary for words made up of those exact characters.")
  3.  
  4. letters = []
  5. uniqueletters = []
  6. lettercount = []
  7.  
  8. possiblewords = []
  9.  
  10. for letter in range(9):
  11.     currletter = input("Enter letter number "+str(letter+1)+"\n").upper()
  12.     if currletter not in(letters):
  13.         uniqueletters.append(currletter)
  14.         lettercount.append(1)
  15.     else:
  16.         lettercount[letters.index(currletter)] += 1
  17.     letters.append(currletter)
  18.  
  19.  
  20. print("All letters:")
  21. print("|C|O|U|N|T|D|O|W|N|")
  22. print("|"+"|".join(letters)+"|")
  23.  
  24. letters.sort()
  25.  
  26. oed = open("English Dictionary.txt").readlines()
  27. #Link to file of words: http://www.mieliestronk.com/corncob_caps.txt
  28.  
  29. for line in oed:
  30.     wordletters = []
  31.     wordlettercount = []
  32.  
  33.     line = list(line[:-1])
  34.  
  35.     for unique in uniqueletters:
  36.         wordletters.append(unique)
  37.         wordlettercount.append(line.count(unique))
  38.  
  39.     StillOK = True
  40.  
  41.     for original, word in zip(lettercount, wordlettercount):
  42.         if original < word:
  43.             StillOK = False
  44.  
  45.         for entry in line:
  46.             if entry not in wordletters:
  47.                 StillOK = False
  48.  
  49.     if StillOK == True:
  50.         possiblewords.append("".join(line))
  51.  
  52. print("\nPossible words you can make with the letters provided sorted by length:")
  53. possiblewords = reversed(sorted(possiblewords,key=len))
  54. print("\n".join(possiblewords))
Advertisement
Add Comment
Please, Sign In to add comment