MIN Match book exactly

The previous code was equivalent, but not equal to the book
ENH Test reversed threshold

The previous code worked well for the example in the book, but was
overly simplified. This is now more general.