The Gordian knot program
Robert R. Korfhage · ACM SIGCSE Bulletin · 1980
A simple device is presented for impressing students with the perils of unbridled "go to" statements. Whether or not one believes in go-to-less programming, it is clear to experienced programmers that unrestrained use of a go to statement leads to programs that are difficult to understand. This is much less clear to students in a beginning course, who see only very short programs. To impress these students that there is a problem, I frequently ask them to rewrite a "Gordian knot" program - one which is more than 50% go to statements - in the shortest possible form. A twenty-line program of this character is easy to construct, and gets the point across. Here is an example, which may be solved either under the assumption that only the very last value computed is needed, or that the final values of all variables (x, y, and z) are needed.