> >>> I couldn't figure out a Perl-ish way of parsing it, > >>> resorting to putting it all in a big 2D array and > >>> scurrying around it. With lots of consistency > >>> checking it takes about 5s to run on my 1.6GHz box > >>> (yikes). > > > > The problem is very similar to PCB tracks in > > electronics. The tracks are the connections between > > the people, and the nodes are the people. The > > orthogonal nature of the grid makes it fairly easy > > to parse... honest :P > > I just wrote a small program to parse the chart line > by line. It's roughly similar to the algorithm you > mentioned. If somebody wants to have a look, the script > is at http://www.stud.uni-karlsruhe.de/~usac/files/sexchart.pl
A serious improvement in speed, 6.8 seconds on an AMD K2/266. I knew I was onto a winner :P I reckon the best solution would be written in C, as a bytewise approach to each line with a FSM would probably work best. The whole thing might be parsed in a small fraction of a second. I had already started working on an impliementation. Maybe my version might be faster, maybe it might not. Either way, this form of algorithm affords tons of consistancy checking for little cost. I can't even imagine how to take the 2d array walk-around approach. Jonathan Paton