Flexible binary search implementation.
Function good is defined for ints from 0 to high-1. Find i such that (i == 0 || !good(i-1)) && (i == h || good(i)). In other words, good(i) is the "first" good = true.
0
high-1
(i == 0 || !good(i-1)) && (i == h || good(i))