Advertisement
J_Bernon

Le compte est bon

Oct 20th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. le compte est bon
  4.  
  5. @author: Julien Bernon
  6. """
  7. import random
  8.  
  9. liste_nombres=[random.randrange(100) for _ in range(100)]
  10. liste_nombres.sort(reverse=True)
  11. objectif=random.randrange(1000)
  12.  
  13.  
  14. def recherche(liste,a_viser,reponse):
  15.  
  16.     for i in range(len(liste)):
  17.  
  18.         if (liste[i]==a_viser):
  19.             reponse.append(liste[i])
  20.             print("gagné")
  21.             print(reponse)
  22.             return reponse
  23.  
  24.         elif(liste[i]<a_viser):
  25.  
  26.             if (i==len(liste)-1):
  27.                 print("perdu")
  28.                 return False
  29.                
  30.  
  31.             else:
  32.                
  33.                 reponse.append(liste[i])
  34.                 return recherche(liste[i+1:],a_viser-liste[i],reponse)
  35.     return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement