This third challenge is adapted from an idea presented by Douglas Hofstadter in his book Metamagical Themas. At the end of this post, you can find a an embedded viewer to some helpful information, contained in Chapters 1 and 2 of the Metamagic Themas book. You are allowed to use any language, unless the challenge specifies a specific language that you are to use. Post your source code, compiler version, and OS as a comment.
Definition:
1) A self-referential sentence is a sentence that describes itself in some manner.
2) The following sentence is an example of a self referential sentence (note that certain letter counts are missing): “This sentence has three a’s, two c’s, two d’s, nineteen e’s, six f’s, two g’s, five h’s, ten i’s, two l’s, twelve n’s, nine o’s, five r’s, twenty six s’s, sixteen t’s, four u’s, four v’s, eight w’s, four x’s, and two y’s.”
Requirements:
1) A function f1 that fills in the the blank in the following sentence: “This sentence, which is also the solution to HacDC’s third programming challenge, has _____.”
1a) f1 must fill in the above blank, with positive integer alpha-numeric phrases related to each letter in the sentence.
1b) f1 may generate a sentence that can contain missingle alpha-numberica phrases, if for example one or more letters are not contained within the sentence.
1c) f1 must return a self-referential sentence.
2) A function f2 that takes as input a self-referential sentence,that was generated by f1, and verifies the validity of the self-referential sentence
Challenge:
Write a program that uses f1, verifying the generated self-referential sentence by using f2, and then displays the valid self-referential sentence.
Language: Any
Difficulty: Metamagical