I was thinking about an approval-style voting system that could end with a large number of ties, and ran into the problem of how to break ties in a provably-fair way that doesn’t depend on candidates trusting each other and won’t make voters’ eyes glaze over.
I think I found a solution which is provably-fair, but it might still cross over into eye-glazing territory. I don’t know if this is practical (or novel), but I’m writing it up in case anyone else finds it interesting.
Today, I found an interesting article about password timing attacks. The basic point is that if you check a password one character at a time, the amount of time it takes to receive a “bad password” response tells you how many characters you got right.
I’ve been subscribed to Interview Cake for years, and today they had a really interesting question: Given a list of n + 1 integers in the range 1...n, find one of the duplicates (there is guaranteed to be at least one) in O(n) time and O(1) additional space. The answer is really interesting, and I recommend trying it, but I don’t think it makes sense to care about additional space rather than total space, and I still think using a set to keep track of numbers (the most obvious solution) is the best solution in practice.
As incomes have risen, it’s important for Americans to find new ways to spend ever-increasing amounts of money. I propose that we spend some of it traveling to pick and eat fresh fruit that doesn’t travel well.
Content Warning: Knowing how delicious fresh fruit can be is an infohazard for your wallet.
There’s a common programming interview question that asks you to find the single non-duplicated value in a list of duplicated integers. This can be done in O(n) time and O(1) space by XOR’ing the values, and doing so is almost always the wrong answer. A better solution when you can afford to do it is to use a hash table to count occurrences.