Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Occur(cards):
- scorelist = [2,4,8]
- counter = collections.Counter(cards)
- largest = [0,0]
- largest2 = [0,0]
- for key in counter:
- occur = counter[key]
- if occur > largest2[1]:
- if occur > largest[1]:
- largest2 = largest
- largest = [key,occur]
- else:
- largest2 = [key,occur]
- num = max([largest[0],largest2[0]])
- if largest[1] == 3 and largest2[1] == 2:
- return(7,largest[0])
- elif largest[1] == largest2[1]:
- return(3,num)
- elif largest[1] in [2,3,4]:
- return(scorelist[[2,3,4].index(largest[1])],num )
- return(1,num)
- def Flush(cards):
- counter = collections.Counter(cards)
- if len(counter) == 1:
- return(True,max(cards))
- return(False,max(cards))
- def Straight(cards):
- if cards[4] - cards[0] == 4:
- return(True,max(cards))
- return(False,max(cards))
- def Royal(cards):
- royal = [0,9,10,11,12]
- if cards == royal:
- return(True,13)
- return(False,13)
- def getScore(hand):
- suit = bubbleSort([i[1] for i in hand])
- value = bubbleSort([i[0] for i in hand])
- occurances = Occur(value)
- if occurances == 2:
- if Flush(suit) == 5:
- if Straight(value):
- return(9)
- if Royal(value):
- return(10)
- return(6)
- if Straight(value):
- return(5)
- return(1)
- return(occurances)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement