Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions