Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import sample
- #Pour modifier le nombre de ville, changer la constante
- NBR_VILLES = 5
- def Valeur(depart,arrivee):
- #Implémenter valeur
- return liste_prix[arrivee - 1]
- def X(n):
- if n < 1:
- raise Exception("n doit être supérieur à 1")
- if n == 1:
- return 0
- if n == 2:
- return Valeur(1,2)
- x1 = X(n-1) + Valeur(n-1,n)
- x2 = X(n-2) + Valeur(n-2,n)
- return min([x1, x2])
- liste_prix = sample(range(100,300), NBR_VILLES)
- print(X(NBR_VILLES))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement