View Single Post
Old 03-23-2005, 11:34 AM   #4 (permalink)
a-j
Tilted
 
I would say if you sort the hand it may be easier, but here is a non-sorted method I came up with, in honor of the IOCCC -- meaning it isn't obvious what I'm doing, maybe you can figure it out.

This is assuming a 5 card hand, if you are doing other sized hands You'll need to modify the check phase steps 7+. I haven't tested this, but I think it is correct

Code:
1. int val = 0;
2. int lowest = Integer.MAX_VALUE;
3. for each card value {
4.   val = val | (1 << card.value);
5.   lowest = Math.min(card.value, lowest);
6. }
7. if (val == 0x3C02) return true;
8. val = val >> lowest;
9. return val == 0x1F;
a-j is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76