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

Let us analyze the shape of the program proposed in the previous hint:

Now, concentrate on what needs to be produced as output for a program of this shape, and how that can be accomplished. The output roughly has the form

fragment_1'SSS'fragment_2

where fragment_1 is actually var S =, and fragment_2 contains some write statements. Producing the middle part ('SSS')is easy, and can be done inside fragment_2 by the following statements, regardless of what we choose voor SSS:

However, fragment_2 needs to be extended to reproduce both fragments that surround the middle part, and it can use string S, the content of which we can still choose. Doing one of these fragments is not too hard. For instance, fragment_1 can be handled by taking SSS equal to fragment_1, and writing S before the quoted part:

Thus, fragment_2 then is

The output () looks like a good start:

but all of fragment_2 is still missing in the output. And we cannot extract it from S.

Getting fragment_2, by itself, is a bit more involved. If we put fragment_2 in S, then fragment_2 should first output the quoted middle part, followed by S. Hence, fragment_2 will look like:

Putting this in S results in the following program (check carefully that this is what it should look like according to the preceding construction):

The output () looks like a good ending:

Apart from the missing var S = at the start, the tail matches perfectly.

Can you develop this into a first solution? (But do remember that all statements on a single line is not acceptable as a final solution, because this violates reasonable coding conventions.)

Try your program in the machine, and see if you can extend it to a complete 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