News for hackers. Stuff that matters.
Re:Who Wants to Be a Thousandaire? (2011) by mattmaroon on Wednesday May 08, 2024 @10:07AM (#40298280)
I had the same thought too, if you take the time to sort the bills the lookups are easy. And it probably doesn’t take much more time to sort them than it does to go through them all once looking for a number.
Re:Who Wants to Be a Thousandaire? (2011) by tromp on Wednesday May 08, 2024 @10:23AM (#40298441)
For a radix sort on the 8 digit USD serial numbers, it takes 8x more time (the 2 letters can be ignored). That could be halved by radix sorting on pairs of digits, but then keeping track of 100 piles instead of 10 probably negates most of the gain. In practice, partial sorting suffices to reduce the serial number search time to a reasonably short amount, e.g. by 4 rounds of radix sorting.
Re:Who Wants to Be a Thousandaire? (2011) by mattmaroon on Wednesday May 08, 2024 @11:48AM (#40299481)
Right, so basically by your ninth time doing this you’d have broken even (ish) on time. He was doing it every day so that’d be a great investment.

It also would reduce the possibility of errors greatly I’d think.

Re:Who Wants to Be a Thousandaire? (2011) by Retric on Wednesday May 08, 2024 @02:09PM (#40301206)
100k bills doesn’t need an exact sort to be vastly faster.

Day one you sort by first digit, then keep sorting matching digits stopping when you have say 20 numbers in a pile. My guess is you break even on day 2 and the first day is only slightly worse.

Re:Who Wants to Be a Thousandaire? (2011) by mattmaroon on Wednesday May 08, 2024 @03:43PM (#40302099)
That’s a good point, each individual sort probably takes only slightly longer than just looking through them for the number. So the actual sorting might not really add much time at all
Re:Who Wants to Be a Thousandaire? (2011) by kragen on Wednesday May 08, 2024 @03:39PM (#40302055)
in a single round of digit-pair radix sorting, you can put 100 piles of ≈1000 bills each into 10×10 cubbyholes, a piece of furniture which is small enough to fit on a desk. then you need about 20 minutes to linearly search through one such pile when the dj announces a number, which is probably fast enough to win

if you have a second cubbyhole array, when you linearly search through a pile chosen from the first cubbyhole array, you can radix-sort that pile by another two digits, dividing it into piles of ≈10 bills. those piles are small enough that you can keep them sorted as you build them without much loss of efficiency, even on a computer

if you can fill the first array with 100 wallets with 10 numbered tabs each, like the tabbed dividers in a looseleaf notebook, you can divide the bills into 1000 piles on the first radix-sorting pass. in practice it might be too much work to find or make the wallets

but i think the sad thing about michael larson's story is not that he didn't know enough about computer 'science' (or, i guess, library 'science'), but that he spent more effort searching for a hack that would make hard things easy than it would have taken to do them the hard way, destroying his personal relationships in the process