Miyago147852

Q8b.py

Apr 24th, 2020
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. import random as rand
  2.  
  3. Cards=[]
  4. cards=[]
  5. suit=[0 for i in range(4)]
  6. symbol=[0 for i in range(13)]
  7. suits=["Shades","Hearts","Diamonds","Clubs"]
  8. symbols=[str(i+1) for i in range(13)]
  9. symbols[0]='A'
  10. symbols[10]='J'
  11. symbols[11]='Q'
  12. symbols[12]='K'
  13. card=[i for i in range(52)]
  14.  
  15. rand.shuffle(card)
  16.  
  17. for i in range(5):
  18.     suit[card[i]//13]+=1
  19.     symbol[card[i]%13]+=1
  20.     cards.append(suits[card[i]//13])
  21.     cards.append(symbols[card[i]%13])
  22.     Cards.append(' '.join(cards))
  23.     cards=[]
  24.  
  25. def Check():
  26.     flush=0
  27.     straight=0
  28.     A_straight=0
  29.     four_of_a_kind=0
  30.     three_of_a_kind=0
  31.     pair=0
  32.     count=0
  33.     for i in range(4):
  34.         if suit[i]==5:
  35.             flush=1
  36.     for i in range(13):
  37.         if symbol[i] != 0:
  38.             end = i;
  39.             if symbol[i]==4:
  40.                 four_of_a_kind=1
  41.             elif symbol[i]==3:
  42.                 three_of_a_kind=1
  43.             elif symbol[i]==2:
  44.                 pair+=1
  45.             elif symbol[i] == 1:
  46.                 count+=1
  47.     if count==5:
  48.         if symbol[0] and symbol[9] and symbol[10] and symbol[11] and symbol[12]:
  49.             a_straight=1
  50.         else:
  51.             start=end-count+1
  52.             for i in range(start,end):
  53.                 if symbol[i]:
  54.                     count-=1
  55.             if count==0:
  56.                 straight=1
  57.     if A_straight and flush:
  58.         return "Royal Straight Flush!!!"
  59.     elif straight and flush:
  60.         return "Straight Flush!"
  61.     elif four_of_a_kind:
  62.         return "Four of a kind!"
  63.     elif three_of_a_kind and pair:
  64.         return "Full House!"
  65.     elif flush==1:
  66.         return "Flush!"
  67.     elif straight or A_straight:
  68.         return "Straight!"
  69.     elif three_of_a_kind:
  70.         return "Three of a kind!"
  71.     elif pair:
  72.         return "Pair!"
  73.     else:
  74.         return "Separate..."
  75.  
  76. print("Result:",Cards)
  77. print("Type:",Check())
Advertisement
Add Comment
Please, Sign In to add comment