Experiments with Knuth's 5,757 five letter words. https://charlesreid1.com/wiki/Five_Letter_Words
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### distinct.py 555 B Raaka Pysyvä linkki Normal View Historia

 compute number of 5-letter words with k distinct letters. 3 vuotta sitten​​updating comment block 3 vuotta sittencompute number of 5-letter words with k distinct letters. 3 vuotta sitten​​​distinct script now uses get_words function. 3 vuotta sittencompute number of 5-letter words with k distinct letters. 3 vuotta sitten​​​​​Make distinct.py more efficient: one loop over words. 3 vuotta sitten​​​compute number of 5-letter words with k distinct letters. 3 vuotta sittenUpdate distinct script to print out some examples. 3 vuotta sittencompute number of 5-letter words with k distinct letters. 3 vuotta sittenUpdate distinct script to print out some examples. 3 vuotta sitten​ 123456789101112131415161718192021222324 ``````""" distinct.py Donald Knuth, Art of Computer Programming, Volume 4 Facsimile 0 Exercise #27 How many SGB words contain exactly k distinct letters, for 1 <= k <= 5? """ from get_words import get_words if __name__=="__main__": words = get_words() lengths = [[] for i in range(5+1)] for word in words: k = len(set(word)) lengths[k].append(word) for i in range(1,5+1): print("-"*40) print("Number of words with {0:d} letters: {1:d}".format(i, len(lengths[i]))) print(", ".join(lengths[i][0:5])) ``````