So I am trying to write a code to determine the odds of getting 7 dominoes with the same number on both sides (7/7).
The dominoes set has double 9 as the highest number on a side. (0/9, 1/9, 2/9, 3/9, 4/9, ..., 9/9). There are 4 people in the game and each person will choose 10 dominoes for their hand. What are the odds that you pull 7/10 dominoes that are doubles.
Thanks for the help!
I've tried changing this code to relate it to dominoes, but don't know how to account for the other 3 players.
class Card:
def __init__ (self):
self.symbol = ""
self.suit = ""
self.key = ""
def show(self):
print(self.symbol, self.suit) #use self. because not a specific function
def setkey(self):
self.key = self.symbol+ "-" + self.suit
thisCard = Card() #creates an instance of the class
thisCard.symbol = "K"
thisCard.suit = "diamonds"
suits = ["hearts", "diamonds", "clubs", "spades" ]
symbols = ["A","2","3","4","5","6","7","8","9","10","J","Q","K"]
deck= []
for symbol in symbols:
for suit in suits:
thisCardInstance = Card()
thisCardInstance.symbol = symbol
thisCardInstance.suit = suit
thisCardInstance.setkey()
deck.append(thisCardInstance)
from random import choice
card = choice(deck) #get random choice from deck
cardnumber, numberofCards = 0, 7
hand = {}
while cardnumber <7 :
card = choice(deck)
while card.key in hand:
card = choice(deck)
hand[card.key] = card
cardnumber +=1
cardkeys = sorted(hand)
for cardkey in cardkeys:
hand[cardkey].show()