>Around 1974 or so I attended a lecture by a Yale professor about monkeys: if you have a room full of monkeys, each banging on a typewriter, eventually you’ll get all of Shakespeare’s works. Using a random number generator to generate characters simulates this process with fewer bananas required.
>
>Of course, not all letters occur with the same frequency. If the typewriter noticed that the monkey typed a “Q”, then it could force the next letter to be “U” with a particular probability. Similarly for other letter pair combinations. One can imagine using some existing text as a model from which to calculate frequencies of letter pairs. How often is “t” followed by “h” ? by “a” ? One can also imagine that extrapolating such 2 letter patterns to n letter patterns can produce even better results.
>
>I wrote a program in C about 20 years ago to simulate the monkeys. I wrote it again in VFP, and found it surprisingly simple to write.
>
>This program can be used on other text, such as programs, or different languages, such as German.
>
>Try experimenting with different pat lengths.
I did this... about five years ago (thread #
257787, "Perfect UT message", August 1999), first using two, then three, four characters. Tried my own language, then English. Eventually I ended up parsing UT messages into arrays of four consecutive words. My code was much longer and convoluted than yours - my only excuse is that I tried to pre-calculate the probabilities and sum them up, for speed's sake. And it was back then in VFP5 days, didn't really know all the stuff I know now.
I hope you had as much fun :).