haste I was going to skip the
ICFP contest this year, but
Luke was talking about his entry-in-progress on IRC Sunday morning and I couldn't resist joining in. With about 6 hours to go I got started on a checker for his entry, writing in C for the sheer perversity of coding the most correctness-critical component in a horribly unsafe language. (Luke's team's code was in Erlang; they'd made a very nice little lightning entry that he was extending with fancier optimizations.) Once the checker was working, Luke was away, leaving me without anything very fun to do, so I decided what the hell and started on a full submission of my own.
How it works:
- Reduce the input to a direct representation of its meaning. This is where all our optimization happens, sad to say.
- Bleed tags into any whitespace characters from the immediately preceding text. This factors out the `space context' so the output routines don't have it to deal with it.
- Write out each character in turn, surrounded by all the tags that decorate it. Well, it's not quite that dumb: it cancels out matching close/open pairs.
There's also a driver script adapted from the Erlang entry that tries to recover from obvious blunders.
It was fun discussing optimization techniques with Luke, though I didn't code any up in the time available. Here's the entry as submitted, embarrassing warts and all:
icfp2001-demoncrat.tar.gzI've been afraid to test it further after the deadline -- what if I found a bug? Leave it alone and pretend it's all right.