[Purdue-pm] September challenge problem: rank poker hands

Mark Senn mark at purdue.edu
Sat Aug 15 19:45:31 PDT 2015


See
    https://en.wikipedia.org/wiki/List_of_poker_hands
for a description of poker hand rankings.  Do not read any other
information on the web about this problem...either documentation,
probability information, Perl modules, any other code in any language,
etc.  This is a programming challenge, not a challenge about how well
one can look up already existing solutions.  I'll only discuss any
solution I come up with via email so any meeting time can be used to
discuss other things.

Devise a data structure for poker hands.

Write a "rank" sub in Perl 5 and/or Perl 6 using only commands built-in to the
language you are using, that given two poker hands dealt from a normal
52 card deck first checks if the hands would be legal in a game of fair
poker, return -2 if the hands are not legal in any way.  Return -1 if
the first hand is ranked below the second hand, 0 if the hands are tied,
and 1 if the first hand is ranked above the second hand.  Assume aces
are used in the way that gives each hand the highest value.  Your "rank"
sub can call any other subs you write if you want.

It is more important that your code be understandable by humans that
run the fastest on a computer.

-mark


More information about the Purdue-pm mailing list