Question: small _ straight ( dice ) - determine if the dice include a small straight. Return True or False. Call has straight ( 4 )

small_straight (dice)- determine if the dice include a small straight. Return True or
False. Call has straight (4) to keep this method short. Note, a large straight also qualifies
as a small straight.
my Program:
ONE_PAIR =10
TWO__PAIR =20
THREE_OF_A_KIND =25
SMALL_STRAIGHT =30
FULL_HOUSE =35
LARGE_STRAIGHT =45
FIVE_OF_A_KIND =50
def tally_dice(dice):
tally =[0]*7
for num in dice:
tally[num]+=1
return tally
def has_straight(length, dice):
tally = sorted(dice)
for i in range(len(dice)- length +1):
if dice[i:i+length]== list(range(dice[i], dice[i]+length)):
return True
return False
def has_multiples(count, dice):
tally = tally_dice(dice)
for num in tally:
if num >= count:
return True
return False
def three_of_kind(dice):
for num in dice:
if dice.count(num)==3:
return True
return False
def four_of_kind(dice):
for num in dice:
if dice.count(num)==4:
return True
return False
def five_of_kind(dice):
for num in dice:
if dice.count(num)==5:
return True
return False
def one_pair(dice):
for num in dice:
if has_multiples(2, dice):
return True
return False
def full_house(dice):
for num in dice:
if one_pair(dice)== True and three_of_kind(dice)== True:
return True
elif five_of_kind(dice)== True:
return True
else:
return False
def two_pair(dice):
if has_multiples(3, dice) or has_multiples(5, dice):
return True
pair_count =0
for num in set(dice):
if dice.count(num)>=2:
pair_count +=1
return pair_count ==2
def small_straight(dice):
for num in dice:
if one_pair == True and has_straight(5, dice):
return True
else:
return False
def large_straight(dice):
if has_straight(5, dice):
return True
 small_straight (dice)- determine if the dice include a small straight. Return

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!