title: Colorizing a table of items
body: <p>I need to show to user a table W x H of short strings. </p>
  
  <p><em>(Update: The table content is not mutable, I can not move strings around, change them etc.)</em></p>
  
  <p>For simplicity sake, let's say that:</p>
  
  <ul>
  <li>I'm visualizing the table using HTML;</li>
  <li>a string is a single word, picked by weighted (by word frequency) random from an English dictionary;</li>
  <li>W and H is in the range from 5 to 10;</li>
  <li>in average case there would be probably 10-15 different words at the same time;</li>
  <li>and in worst case all words in the table are different (that is up to 100 different strings). </li>
  </ul>
  
  <p>To help visualization, I need to colorize backgrounds of the table cells. Cells with the same word should be of the same color.</p>
  
  <p>The question is what is a good algorithm to assign colors to strings in this case?</p>
  
  <p><em>Additional requirements and notes:</em></p>
  
  <ul>
  <li>I do not want to use a hardcoded table of 100 colors, that's not fun.</li>
  <li>Colors should be as visually distinguishable as possible (but with 100 colors that's hard to achieve). </li>
  <li>Alternatively — adjacent cell colors must be as visually distinguishable as possible (as long as they contain different words, of course). But that will complicate algorithm.</li>
  <li>I would like text in each cell to be in the same color (say, black) if possible. Again, this is hard to do with 100 colors. But at the very least, the text should be as readable as possible with any background color. </li>
  <li>Ideally, I would like to do everything in a single pass for simplicity sake and assign colors on the go — but this would harm the distinguishability. So, two passes, I guess.</li>
  <li>In general, performance does not matter, readability and algorithm simplicity do.</li>
  </ul>