Self-documenting Sentences

Self-documenting sentences of the sort offered by the applet below, have been invented by Raphael Robinson [Hofstadter, p 27 and p 389 and on; see also Gale, p 10]. The puzzle is to fill in the blanks in "This sentence contains _ 0's, _ 1's, _2's, _ 3's, _ 4's, _ 5's, _ 6's, _ 7's, _ 8's, and _ 9's" so that the sentence become true. A curious approach to solving the puzzle is by iterations. Fill blanks arbitrarily, count the number of 0's, 1's and so on, and feed thus obtained numbers back into the sentence in place of the initial selection. Again count the number of various digits and substitute the result into the sentence. The iterations are documented in the drop-down box at the bottom of the applet. (The "Clear" button clears the contents of the box.) The truth to be said, such iterations do not always lead to solutions. Sometimes they settle into cycles. Moreover, there are solutions of the repelling sort that can't be obtained by the iterations. So not all fun can be automated. (The "Iterate" button performs a single iteration. The "Auto" button runs until "Stop"ed or until a solution is found. Numbers that fill the blanks can be changed up or down manually by clicking a little off their center line.)

If you see the graphics below, your browser is not set to run Java applets. Try IE11 or Safari and declare the site https:///www.cut-the-knot.org as trusted in the Java setup.

 What if applet does not run?

Explanation

References

1. D. Gale, Tracking the Automatic Ant, Springer, 1998
2. H. P. Ginsburg, Children's Arithmetic, II edition, pro-ed, 1989
3. D. R. Hofstadter, Metamagical Themas, Basic Books, Inc., 1985

There is also a shortened variant with a different set of solutions.