It's Time to Make Software Accessible
queue.acm.org1 pointsby munch1170 comments
# INPUT: lookfor: unicode
var lower, upper: ascii
lower = ascii_lower_bound(lookfor)
upper = ascii_upper_bound(lookfor)
for candidate:ascii in index_lookup(lower .. upper):
if expensive_correct_compare_equal(candidate.field, lookfor):
yield candidate
The magic is to have functions ascii_lower_bound and ascii_upper_bound, that compute an ASCII string such that all ASCII strings that compare smaller (greater) cannot be equal to the input. Those functions are not hard to write. Although you might have to implement versions for each supported locale-dependent text comparison algorithm, but still, not a big deal. $ login '-f root'
login: illegal option --
What's telnetd doing differently? Is it invoking login via a shell? def close(self):
self._closed = True
self.do_interesting_finalisation_stuff()
def __del__(self):
if not self._closed:
print("Programming error! Forgot to .close()", self)
If you do anything the slightest bit more interesting than that in your __del__, then you are likely to regret it. - If the first guess is within a factor of sqrt(10), then you win.
- If not, you are given two choices for the second guess: Up or down.
- Up and down are 10x higher and lower guesses (making them adjacent ranges to the first guess).
- If the second guess is wrong, you lose. No more guesses.
The point is that the second guess makes you rethink the original question once more, to figure out what it was that you missed. Which is more fun that doing bisection.