--------------090207040103080909040600
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Here is my solution.  No fancy graphics, the kids didn't give me enough 
time for that ;)

-Doug Seifert

--------------090207040103080909040600
Content-Type: application/x-ruby;
 name
utomaton.rb"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename
utomaton.rb"

Y2xhc3MgQXV0b21hdG9uCiAgYXR0cl9hY2Nlc3NvciA6cnVsZV9udW1iZXIKICBhdHRyX3Jl
YWRlciA6cnVsZV9tYXAKCiAgRklMTEVEX0NIQVIgPSAnIycKICBFTVBUWV9DSEFSID0gJzAn
CgogICMgQ29uc3RydWN0IGEgbmV3IEF1dG9tYXRvbiB3aXRoIHRoZSBnaXZlbiBydWxlIG51
bWJlciBhbmQgaW5pdGlhbAogICMgbGluZSB3aWR0aAogIGRlZiBpbml0aWFsaXplKHJ1bGVf
bnVtYmVyLCBpbml0aWFsX3N0YXRlKQogICAgQHJ1bGVfbnVtYmVyID0gcnVsZV9udW1iZXIK
ICAgIEBjaGFycyA9IGluaXRpYWxfc3RhdGUubGVuZ3RoCiAgICBAbnVtID0gMAogICAgaW5p
dGlhbF9zdGF0ZS5yZXZlcnNlLnNwbGl0KC8vKS5lYWNoX3dpdGhfaW5kZXggZG8gfGMsIGlk
eHwKICAgICAgQG51bSArPSAyICoqIGlkeCBpZiAnMScgPT0gYwogICAgZW5kCiAgICBpbml0
aWFsaXplX3J1bGVfbWFwCiAgZW5kCgogICMgU2V0cyB1cCB0aGUgYXV0b21hdG9uIHJ1bGUg
bWFwLiAgR2l2ZW4gYSAzIGJ5dGUgbmVpZ2hib3Job29kCiAgIyBhcyBhbiBpbnRlZ2VyLCB0
ZWxscyB3aGV0aGVyIHRoZSBuZXcgY2VudGVyIGNlbGwgaXMgZmlsbGVkIG9yIG5vdC4KICBk
ZWYgaW5pdGlhbGl6ZV9ydWxlX21hcAogICAgQHJ1bGVfbWFwID0gW10KICAgIG4gPSBAcnVs
ZV9udW1iZ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