Last updated 1999-07-12.
Here's the program:
char b[2000],m[]={1,-80,-1,80};main(){int i,x=1000,s=2000,d=0;while(1+(i= getchar()))switch(i){case'f':b[x]=1;case'g':x=(x+m[d/2]+s)%s;d--;case'+':d+=2; case'-':d+=7;d%=8;}for(i=0;i!=s;i++)putchar(" #"[b[i]]);}
It should compile without difficulty on any Unix system with a command like "cc junk.c -o puz5"; try gcc if you don't have cc installed. It should probably also compile without difficulty on other systems.
It takes a text file as input; the text file contains turtle-graphics commands. 'f' means go forward and draw a line, '+' means turn left an eighth of a turn, '-' means turn right an eighth of a turn, and 'g' means to go forward without drawing a line. Other characters are ignored. You can type these commands in 'interactively', and when you hit control-D (on Unix) or control-Z (on Microsoft platforms), it will draw the result.
The forty-five degree thing doesn't really work, but it's helpful for one thing I wanted to do with this.
Here are some sample inputs:
ff++ff++ff++ff ff++ff++ff++ffggff++ff++ff++ff f++g--f++g--f++g--f++g--f--g++f--g++f--
This is mostly interesting because you can write programs to draw cool pictures by having them generate strings of f's and g's, like the fourth puzzle .signature.
There is a line-by-line explanation of how this program works.