# 5 Card Hand Evaluator

**URL:** <https://www.ruby-forum.com/t/5-card-hand-evaluator/104352>\
**Category:** Ruby\
**Created:** [May 17, 2007, 1:32am UTC](https://www.ruby-forum.com/t/5-card-hand-evaluator/104352 "2007-05-17T01:32:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [May 17, 2007, 1:32am UTC](https://www.ruby-forum.com/t/5-card-hand-evaluator/104352/1 "2007-05-17T01:32:34Z")

</div>

I’ve just finised writing a 5 card hand evaluator (I’m avoding the ‘pkr’  
word since the spam filter won’t let me post when I use that word),  
using the algorithm found: [http://www.suffecool.net/\*/evaluator.html](http://www.suffecool.net/*/evaluator.html) (\<\<  
replace \* with the ‘pkr’ word, same in the next link \>\>).

You can download it from here:  
[http://www.btinternet.com/~douglas.marsh/\*.zip](http://www.btinternet.com/~douglas.marsh/*.zip)

Use the ‘eval’ method. For the purposes of this code a card is defined  
as an array where element [0] is a number 0…12 (0 = two, 1 = three …  
11 = king, 12 = ace) and element [1] is a number 0…2 (0 = clubs, 1 =  
diamonds, 2 = hearts, 3 = spades).

The lower the value returned, the higher-ranking the hand. Enjoy.
