Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Judge all of them solution in Clear category for Texas Referee by DiZ
def texas_referee(cards_str):
from itertools import combinations
RANKS, SUITS = "AKQJT98765432", "hdcs"
card_sort = lambda card: (RANKS.index(card[0]), SUITS.index(card[1]))
def score(cards):
value, straight, flush = 0, '', set()
for rank, suit in cards:
value += cards_str.count(rank)
straight += rank
flush |= {suit}
return value + 7 * (straight in RANKS) + 8 * (len(flush) == 1)
return ','.join(max(combinations(
sorted(cards_str.split(','), key=card_sort), 5), key=score))
April 13, 2015
Comments: