master: Getting closer. This algorithm has a fatal flaw, though, but I think I've come up with a simpler one. On to implement
master: New algorithm, once I stopped making novice mistakes with it, works great. Single prior pointer, with incremented lookahead and three cases. Beautiful.