Skip to main content

Timeline for Represent a 5 card poker hand

Current License: CC BY-SA 3.0

28 events
when toggle format what by license comment
Apr 7, 2017 at 11:34 history edited paparazzo CC BY-SA 3.0
added 2012 characters in body
Apr 7, 2017 at 11:33 vote accept paparazzo
Apr 6, 2017 at 23:58 vote accept paparazzo
Apr 6, 2017 at 23:59
Apr 6, 2017 at 23:42 answer added gnasher729 timeline score: 3
Apr 6, 2017 at 16:12 answer added Yuval Filmus timeline score: 10
Apr 6, 2017 at 15:19 comment added paparazzo @YuvalFilmus Please forget how I am using this key. I have 5 values 1-52. Value cannot repeat in the 5. Order does not matter. 22 15 50 3 7 must equal 3 7 22 15 50 . What is the smallest number to uniquely identify the 5 where they are not first sorted. For example I could use the first 52 primes and multiply but that is bigger than 2 power 52.
Apr 6, 2017 at 15:05 comment added Yuval Filmus What do you mean by key? Do you want two hands which are the same up to order to map to the same key?
Apr 6, 2017 at 11:21 comment added paparazzo @MSalters As stated in my question. A sort doubles the time for the method. Can you just accept the stated question? I am looking for a key of 5 numbers 0-51 where the numbers can be in any order and the key is still less than or equal 32 bits. I am not really sorting the numbers - I am feeding the the number pre sorted.
Apr 6, 2017 at 11:14 comment added MSalters @Paparazzi: Just in case you hadn't realized it, the existing answer is far more complex than sorting 5 6-bit values using a dedicated sorting network. Sure, you may have millions of hands, but such a simple sort can be done tens of millions of times per second. Randomly generating the hand will also be slower than sorting it.
Apr 6, 2017 at 11:04 comment added paparazzo @MSalters I am asking for 32 bits or less that does not require the 5 numbers be sorted.
Apr 6, 2017 at 11:02 comment added paparazzo @DavidRicherby Not even close. I am not using a library. It is not sorting on the number directly. I insert the numbers pre sorted.
Apr 6, 2017 at 9:01 review Close votes
Apr 14, 2017 at 3:05
Apr 6, 2017 at 9:00 comment added MSalters In practice, most items that are not <=16 bits might as well be 32 bits. So since you need at least 23 bits, any encoding which uses <=32 bits is probably viable. The trivial 6 bits per card * 5 card encoding works well enough. There's one caveat: a 23 bit array index is much better than a 32 bits array index.
Apr 6, 2017 at 8:48 comment added David Richerby @Paparazzi No, Yuval is telling you to write your own sorting routine that is specifically tuned to sorting five numbers between 1 and 52. You tried using a library routine, which is slow because it is much more general than this and because the recursive nature of quicksort makes it very inefficient on short lists.
Apr 6, 2017 at 4:33 history tweeted twitter.com/StackCompSci/status/849842427808624640
Apr 6, 2017 at 2:04 history edited paparazzo CC BY-SA 3.0
added 1 character in body
Apr 6, 2017 at 1:52 history edited paparazzo CC BY-SA 3.0
added 214 characters in body
Apr 6, 2017 at 0:37 comment added paparazzo @dw Yes the sort is simple but what I am doing (millions of times) is simple. I tested and a sort doubles the time.
Apr 6, 2017 at 0:36 history edited paparazzo CC BY-SA 3.0
added 142 characters in body
Apr 5, 2017 at 21:49 comment added D.W. I don't understand why you say "The sort is not simple". The sort is simple -- convert each card to a number from 1 to 52, so that the hand is represented by a list (of length 5) of cards. Sort that list. That is just the problem of sorting a list of 5 integers, which can be done very fast, as Yuval mentions. I suggest that you measure before assuming that it is too slow, but my guess is that sorting such a list will be very fast and might even be faster than a random-access memory read that doesn't hit in the cache.
Apr 5, 2017 at 21:30 history edited paparazzo CC BY-SA 3.0
added 159 characters in body
Apr 5, 2017 at 21:10 history edited paparazzo CC BY-SA 3.0
added 25 characters in body
Apr 5, 2017 at 20:56 history edited paparazzo CC BY-SA 3.0
added 106 characters in body
Apr 5, 2017 at 20:47 comment added Yuval Filmus Use a hand-coded sorting algorithm which works for sorting lists of length 5. This is probably faster than the library function you're currently using.
Apr 5, 2017 at 20:45 history edited paparazzo CC BY-SA 3.0
added 308 characters in body
Apr 5, 2017 at 20:31 history edited paparazzo CC BY-SA 3.0
added 320 characters in body
Apr 5, 2017 at 20:29 answer added D.W. timeline score: 13
Apr 5, 2017 at 20:15 history asked paparazzo CC BY-SA 3.0