Chapter 15
Files
Working with large blocks of text in a file opens up a whole new range of
possibilities for interesting programs. The following program solves Jumble
puzzles, which ask the solver to figure out an unknown word given a scrambled
set of its letters.
One of the difficulties in solving this problem is that long words have so many
different reorderings, called p ermutations. The strategy employed here is to
create a unique signature for each word, so that a word has the same signature
as all of its permutations. This program also finds anagrams, since typing in
an unscrambled word will find all of its anagrams.
Listing 15.1: Solve Jumble
1 # solvejumble.py ...

Get A Concise Introduction to Programming in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.