I suspect there must be a way to break a spec like this into two parts, one is the spec for the algorithm, and the other is ascaffolding
spec to contain all the auxiliary stuff needed to fully test the algorithm, much like the tests and test harness for production software.