Hints for the Challenge:

Below, you can find another hint for the Challenge.

You should only get here after reading, digesting, and applying the .

Hint

It is more conventient to change the name of the global variable S after introducing parameters for the functions. The reason is that the name of the global variable now appears in many places.

It only seems natural to give the function copy() one string parameter, say s, which copy(s) will write (copy) to the output as a multi-line string expression having value s. That way, the function copy(s) has become a more general tool, because it now works for any argument s and not only for the global variable. Such a more general function is often easier to understand, and easier to verify and test.

Similarly, we can give the function transcribe() a string parameter. To make transcribe() even more general, we can give it two string parameters s and t, where transcribe(s, t) will transcribe string s to the output, inserting a copy of t in the appropriate place. (How to determine that place more conveniently is a later problem.)

Again, we can bring about these changes by first adapting the blueprint, and then taking the output as our new program. Here is the program with a new blueprint, where the functions have parameters:

It outputs ():

This new program outputs itself ().

Can you improve this solution further? On the wish list we still have:

  1. Rename the global variable to something more meaningful than S.
  2. Get rid of the awkward literals, such as , etc.
  3. Allow the use of any character in the program, including quotes and vertical bars (these are now forbidden, because transcribe() misinterprets them).

Try your program in the machine, and see if you can extend it to an improved solution.

Apply the Hint

It is your turn ...

Need Another Hint?

If you tried this hint, or do not see how it helps, then you are ready for the .


Valid HTML 4.01 Transitional

Copyright ©2009, Tom Verhoeff, T.Verhoeff@TUE.NL