I want to keep the test input separately, to use it for testing alternative implementations, for instance. I hope the idea is clear, but the code seems to me accidental and ugly. Is there a way to make it more natural? Or have I done it just right at my first attempt?
I mean... I hesitate to make any pronouncements about "right/wrong"
I find that, while it is very useful to have "goldilocks" code, i.e. everything is "just right", I often experience that my sense of "just right" changes over time.
A comment or two usually does a better job to clarify what it is I mean, if the code itself can't be persuaded into something more "self-evident".
As an aside, I recently started reading Don't Make Me Think by Steve Krug, and he makes a good point about settling for "self-explanatory" instead of "self-evident" when it is not evident (haha) what that should be exactly.