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

Actually, for a poker hand evaluator the last thing you want to do is sort the hands. There's a small enough number of unique card combinations that you can arrange it so that you look up in pre-computed tables more often than not.

One clever trick is assigning a prime to each card value. By multiplying the values together you get a unique number representing each hand without needing to sort.

There's a great description of an algorithm at http://www.suffecool.net/poker/evaluator.html.



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

Search: