Question: small _ straight ( dice ) - determine if the dice include a small straight. Return True or False. Call has straight ( 4 )
smallstraight dice determine if the dice include a small straight. Return True or
False. Call has straight to keep this method short. Note, a large straight also qualifies
as a small straight.
my Program:
ONEPAIR
TWOPAIR
THREEOFAKIND
SMALLSTRAIGHT
FULLHOUSE
LARGESTRAIGHT
FIVEOFAKIND
def tallydicedice:
tally
for num in dice:
tallynum
return tally
def hasstraightlength dice:
tally sorteddice
for i in rangelendice length :
if dicei:ilength listrangedicei diceilength:
return True
return False
def hasmultiplescount dice:
tally tallydicedice
for num in tally:
if num count:
return True
return False
def threeofkinddice:
for num in dice:
if dice.countnum:
return True
return False
def fourofkinddice:
for num in dice:
if dice.countnum:
return True
return False
def fiveofkinddice:
for num in dice:
if dice.countnum:
return True
return False
def onepairdice:
for num in dice:
if hasmultiples dice:
return True
return False
def fullhousedice:
for num in dice:
if onepairdice True and threeofkinddice True:
return True
elif fiveofkinddice True:
return True
else:
return False
def twopairdice:
if hasmultiples dice or hasmultiples dice:
return True
paircount
for num in setdice:
if dice.countnum:
paircount
return paircount
def smallstraightdice:
for num in dice:
if onepair True and hasstraight dice:
return True
else:
return False
def largestraightdice:
if hasstraight dice:
return True
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
