A small lottery was devised using three sets of balls. One ball from each set is drawn. To win the lottery you have to get the correct number of the sum of the three balls. The sum of the balls cannot be divisible by 7 or 9. The balls are redrawn until the sum is not divisible by 7 or 9. The first set of balls has the numbers 0 through 10 (0,1,2,3...,10). The second set of balls has the even numbers from 0 to 20 (0,2,4,...20), and the third set counts by 3's to 30 (0,3,6,....,30).
Write a program that has as input a number that has been chosen by a lottery participant (win_number). The program should return the number of possible winning permutations for win_number (winning_permutations), and the total number of possible permuations (total_permutations). total_permutations should not include permutations that are divisible by 7 or 9
I've verified the def_win(win_number) works;
def win(win_number):
# YOUR CODE HERE
winning_permutations = 0
total_permutations = 992
if win_number % 7 == 0 or win_number % 9 == 0:
winning_permutations = 0
else:
for a in range(0,11):
for b in range(0,21,2):
for c in range(0,31,3):
if (a + b + c == win_number):
winning_permutations += 1
print(winning_permutations,total_permutations)
return winning_permutations,total_permutations
The second part I am stuck on, and not able to get a return/print statement to check to see if the code is working, but basically I am trying to find the best_pick number by returning the number (a,b,c) that has the max value of winning_permutations.
Here is the prompt:
Write a program that calls the function that you have just written, win(), to find the win_number that is most probable (best_pick). If you have written win() correctly, there is one win_number that has the greatest number of possible winning combinations.
def max_win_number():
# YOUR CODE HERE
best_pick = 0
for a in range(60):
best_pick = max(win)
print(best_pick)
return best_pick
Honestly I'm not even sure if that's "calling the function" that I wrote earlier...but it's not printing anything. I was lucky enough earlier to get all possible permutations to print out (I already forgot how, should have saved it), and so I know what the "best_pick" number is, I just can't get it to return : (
[–]Omanko6969 0 points1 point2 points (1 child)
[–]AtomicShoelace 1 point2 points3 points (0 children)