Question: PYTHON REQUIRED Bonus (4 points): Why was 6 afraid of 7? Because 7 89! Actually, this is mathematically impossible. Cannibal numbers as they're called can

PYTHON REQUIRED PYTHON REQUIRED Bonus (4 points): Why was 6 afraid of 7? Because

Bonus (4 points): Why was 6 afraid of 7? Because 7 89! Actually, this is mathematically impossible. "Cannibal numbers" as they're called can only eat numbers that are smaller than them, or the same size. After eating another number, the number that gets eaten disappears, and the number that ate them increases by 1 For example, given the following set of numbers, let's pretend that 9 is the cannibal. 127, 9,3, 8, 11] 9 could start by eating 3 or 8. Let's say it eats 3, then the numbers would be: [27, 10, 8, 11) Then it could eat 8, so the numbers would be: [27, 11, 11] And lastly, it could eat 11 (27, 12] Your task is to write a program that, given a list of numbers and a target number, determines how many numbers in the list can become exactly that number For instance, in our example, two numbers could reach the value of 10. As we saw, 9 took on that value in the example. However, if 8 were the cannibal, it could .Eat 3 to become 9 Eat 9 to become 10 So it could also hold the value of 10 For a target value of 11, the answer would also be 2, because 9 can become 11, and 11 is already 11 Your function may be passed a string of values separated by commas instead of a list--1 out of 4 points will be awarded for handling this case correctly [ ]: Write your answer here. ]: 3, 8, 11], 11) 2 9, [1: cannibal([27, 9, 3, 8, 11, 50) 0 3, [ cannibal ( [27, [ ]: cannibal ( [3, 3, 2, 2, 2, 1, 1, 1], 4) 9 [ ]: cannibal ( "1,2,3,4,5", 5) -4

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!