title: How do I resolve the "Crypt Kicker" exercise proposed in "Programming Challenges (The Programming Contest Training Manual)"?
body: <p>"Programming Challenges (The Programming Contest Training Manual)" is probably one of the nicest exercises book on algorithms.
  I've resolved the first 11 exercises, but now I am stuck with "Crypt Kicker" problem:</p>
  
  <blockquote>
    <p><strong>Crypt Kicker</strong><br>
    A common but insecure method of encrypting text is to permute the letters of the alphabet.
    In other words, each letter of the alphabet is consistently replaced in the text by some other letter. To ensure that the encryption is reversible, no two letters are replaced by the same letter.</p>
    
    <p>Your task is to decrypt several encoded lines of text, assuming that each line uses a different set of replacements, and that all words in the decrypted text are from a dictionary of known words.</p>
    
    <p>Input<br>
    The input consists of a line containing an integer n, followed by n lowercase words, one per line, in alphabetical order. These n words compose the dictionary of words which may appear in the decrypted text.<br>
    Following the dictionary are several lines of input. Each line is encrypted as described above.</p>
    
    <p>There are no more than 1,000 words in the dictionary. No word exceeds 16
    letters. The encrypted lines contain only lower case letters and spaces and
    do not exceed 80 characters in length.  </p>
    
    <p>Output<br>
    Decrypt each line and print it to standard output. If there are multiple solutions, any one will do.<br>
    If there is no solution, replace every letter of the alphabet by an asterisk.</p>
    
    <p><em>Sample Input</em> 6<br>
      and<br>
      dick<br>
      jane<br>
      puff<br>
      spot<br>
      yertle</p>
    
    <p>bjvg xsb hxsn xsb qymm xsb rqat xsb pnetfn<br>
      xxxx yyy zzzz www yyyy aaa bbbb ccc dddddd</p>
    
    <p><em>Sample Output</em><br>
     dick and jane and puff and spot and yertle ...</p>
  </blockquote>
  
  <p>What <em>strategy</em> should I to take in order to resolve this exercise? I was thinking to a classic and brutish backtracking solution, but I am trying avoid that until I find something more intelligent.</p>
  
  <p>PS: This is not homework related, I am just trying to improve my overall skills.</p>