Jun-27-2018, 06:39 PM
Hi,
Excuse me for my english .....
I have a problem with a test.
I must to calculate the different possibility to make a rugby score (try (5 points), try with transformation (7 points), penalty(3 points)).
The score is 88
my code :
combinaison x 0 y 1 z 27
combinaison x 1 y 2 z 23
combinaison x 3 y 4 z 15
combinaison x 7 y 5 z 6
combinaison x 1 y 2 z 23
combinaison x 3 y 4 z 15
combinaison x 7 y 5 z 6
combinaison x 2 y 0 z 26
combinaison x 2 y 3 z 19
combinaison x 5 y 6 z 7
combinaison x 3 y 1 z 22
combinaison x 4 y 2 z 18
combinaison x 6 y 4 z 10
combinaison x 10 y 5 z 1
In my list, for example, I don't have the solution (0 4 20) but it's a valid solution
0 * 5 + 4 * 7 + 20 * 3 = 88
So why I don't have this solution in my resultat ? It's only three "For"....
If somebody have an idea ...
Thanks by advance for you ideas......
Excuse me for my english .....
I have a problem with a test.
I must to calculate the different possibility to make a rugby score (try (5 points), try with transformation (7 points), penalty(3 points)).
The score is 88
my code :
def calculSolution(n): solution=[] ligne=[] for x in range(0,100) : for y in range(0,100) : for z in range(0,100) : if 5*x+7*y+3*z==n : print ("combinaison x %d y %d z %d " %(x,y,z)) x=x+y ligne=(x,y,z) solution.append(ligne) # solution=set(solution) return solutionan example of solutions find :
combinaison x 0 y 1 z 27
combinaison x 1 y 2 z 23
combinaison x 3 y 4 z 15
combinaison x 7 y 5 z 6
combinaison x 1 y 2 z 23
combinaison x 3 y 4 z 15
combinaison x 7 y 5 z 6
combinaison x 2 y 0 z 26
combinaison x 2 y 3 z 19
combinaison x 5 y 6 z 7
combinaison x 3 y 1 z 22
combinaison x 4 y 2 z 18
combinaison x 6 y 4 z 10
combinaison x 10 y 5 z 1
In my list, for example, I don't have the solution (0 4 20) but it's a valid solution

0 * 5 + 4 * 7 + 20 * 3 = 88
So why I don't have this solution in my resultat ? It's only three "For"....
If somebody have an idea ...
Thanks by advance for you ideas......