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

That makes sense. I was making the assumption that hands are given in order. For example, when generating all hands, your inner loops only start at the current index of the parent loop.


The purpose isn't to generate the ranking list. The purpose is to evaluate hands. The list is a one-time cost however you make it, but evaluating the randomly dealt cards would have the ongoing cost of sorting every time if not for the prime-factors trick.


Yea, I guess I'm not convinced that the prime-factors is faster than sorting. Sure, linear time for prime multiplication, but you still have to look up the prime number in a lookup. The question comes down to what the coefficient is in front of N for prime factor method and in front of N log N for sorting. As N=5, the coefficient ratio is pretty small to still warrant using sorting. Also, using Radix sorting makes things even more fuzzy.




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

Search: