I have to say that this challenge wasn't quite such as success that I hoped for. There were very few participants compared to e.g. the $isdate challenge. Are the challenges I'm setting too difficult? Anyway, on to the results...
There was a total of 6 entries of which 3 were valid and 3 were invalid.
alias + if ($3) inc %f $calc(18^($iif($pos(%e,$mid(%e,-1),5),5)+$2)*$1)
alias holdem {
tokenize 32 $replace($1,T,B,10,T)
%a = 0
%b = $0
while %b {
%c = $(,$ $+ %b)
dec %b
%d = %b
while %d {
%e = $deltok($remove($1-,%c),%d,32)
%f =
var %2,%3,%g,%h,%i 1
while $mid(23456789TJQKA,%i,1) {
%j = $count(%e,$v1)
inc %g %j
+ %i $token(%g $iif(%2,7,6) 8 12,%j,32) %j
var % $+ %j %i,%h %h $+ %j
inc %i
}
+ %3 11 %2
+ $pos(%j $+ %h,11111) 9 1
if $mid(%c,2) !isin S D C H || (%g != 5) %a =
if (%f > %a) %a = %f
dec %d
}
}
return %a
Not quite so enigmatic as his last bit of code, but still beautiful.
Also, due to the lack of participants, I tried to be a bit forgiving when it came to juding the entries. Jaytea's entry has a few validation problems, as does urza's entry, but I didn't want to make these invalid. However, it was completely unacceptable for a script to not work at all (myndzi) and for the fundamental rules of poker to slip by them (NaquadaBomb)... as as for visionz entry, well, I was tempted to mark it invalid instantly. But I gave it a chance ;)
It will be quite a while before I set a new challenge. If you have any ideas for this challenge please private message garreh.
In this challenge you are asked to code an alias that will return what the score of a player's hand is.
Card naming scheme
A
Ace
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
J
Jack
Q
Queen
K
King
D
Diamond
H
Heart
S
Spade
C
Club
Specfications
The alias will accept one parameter ($1) which should be exactly seven cards.
Each card is seperated by a space and represented in the format:
[card][suit]
Parameter one ($1) is the only used parameter; all of the other parameters ($2-) should be ignored.
Potential incorrect inputs may include (but are not limited to) the following:
Incorrect number of cards (not 7 cards)
Duplicate cards (pay attention to this one!)
Incorrect card formatting, e.g. 4DD instead of 4D
In each of these cases and any other erroneous inputs, the identifier should return $null. You will assume anything can be supplied as a parameter. All of the above conditions will be checked.
Your alias must be case-insensitive, e.g. "4d" is the same as "4D".
Scoring System
In terms of the scoring system, it is up to you to come up with a scoring system. Whatever scoring system you use, you have to follow this simple rule; the higher the number, the higher the hand is rated, e.g. 500 could be three of a kind, 400 could be two pair.
You are allowed to use decimals, or even negative values, just as long as it follows the above rule.
Do not forget you need to factor in high cards and kickers. You should always have five cards factored into your score.
Hand
Fours full of Aces
Straight 2-6
Royal Flush
Straight flush 6-10
Four of a kind, queens, 7 kicker
Flush, diamods, king high
Straight, 4-8
Three of a kind, queens, King kicker
Two pair, Jacks and Nines, 10 kicker
Two pair, Kings and fours, Queen kicker
Ace High
$null
$null
$null
$null
* These examples do NOT specifically represent what the alias should return. They should only be used as a reference.