Question: Implement the free_bacon helper function that returns the number of points scored by rolling 0 dice, based on the opponent's current score. You can assume

Implement the free_bacon helper function that returns the number of points scored by rolling 0 dice, based on the opponent's current score. You can assume that score is less than 100.

Free Bacon. A player who chooses to roll zero dice scores points equal to one more than the absolute alternating difference of the digits of the opponent's score cubed.

Example: The opponent has 4 points, and the current player chooses to roll zero dice. 4*4*4 = 64, so the current player gets 1 + |6 - 4| = 3 points.

def free_bacon(score): """Return the points scored from rolling 0 dice (Free Bacon).

score: The opponent's current score. """ assert score < 100, 'The game should be over.' # BEGIN PROBLEM 2 sum, odd_sum, even_sum = 0, 0 ,0 i = 0 curr_score = score ** 3 while i < len(curr_score): if (i+1) % 2 == 0: even_sum += curr_score(i) else: odd_sum += curr_score(i) i += 1 score = curr_score // 10 total = 1 + abs(odd_sum - even_sum) return total

I couldn't get it to return the result I wanted. Can someone help?

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!