Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- c10 = set()
- c9 = set()
- # Get Scrabble words of length 10 and 9
- words_str = requests.get('http://norvig.com/ngrams/enable1.txt').content.decode('utf-8')
- for l in words_str.split('\n'):
- l = l.strip()
- if len(l) == 10 and 't' in l:
- c10.add(l)
- elif len(l) == 9:
- c9.add(l)
- # Sort the 9-letter ones
- c9_sorted = set(''.join(sorted(x)) for x in c9)
- #%%
- # Remove a t, sort, and see if it makes a word
- ct = 0
- transdelete_words = []
- for w in c10:
- w1 = w.replace('t', '', 1)
- w1_sorted = ''.join(sorted(w1))
- if w1_sorted in c9_sorted:
- ct += 1
- transdelete_words.append(w)
- print(len(c10))
- print(ct)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement