Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>"A stable matching algorithm" is the real trick here.

What about randomizing bids and asks, and matching them on a first-come, first-serve basis?

Let's say you had bids like this 10, 12, 9, 5; and asks like this 11, 12, 10. You randomize the the bids, and sort the asks. Then you do a linear search for the first ask that is <= to that bid, and that's an order. You remove the bid and ask from the lists, and repeat until bids and asks are removed. If there is no ask that is <= the bid, the bid gets popped.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: