On thy own heads be it. Here is the code, as written when I was 16. You'll need Tcl 8.5 to run it (8.3 is probably fine, but you'll have to change the line at the beginning), because all the cool kids implement interpreted languages in other interpreted languages. (Actually, wasn't Arc implemented that way originally?)