Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Thu Dec  5 11:40:57 2019
  5.  
  6. @author: dario
  7. """
  8. import random
  9.  
  10. #album = [0,0,0,0,0,0,0,0,0,0]
  11. #figuritas_sacadas=0
  12. #
  13. #while 0 in album:
  14. #    figurita = random.randint(0,9)
  15. #    album[figurita] = 1
  16. #    
  17. #    figuritas_sacadas = figuritas_sacadas + 1
  18.  
  19.  
  20.  
  21. def comprar_una_figu(figus_total):
  22.     return random.randint(0, figus_total-1)
  23.  
  24. def esta_lleno(album):
  25.     return not (0 in album)
  26.  
  27. def cuantas_figus(figus_total):
  28.     album = []
  29.     i = 0
  30.     while i < figus_total:
  31.         album.append(0)
  32.         i=i+1
  33.  
  34.     contador = 0
  35.     while not(esta_lleno(album)):
  36.         figu = comprar_una_figu(figus_total)
  37.         album[figu] = 1
  38.         contador = contador + 1
  39.        
  40.     return contador
  41.  
  42. res = cuantas_figus(6)
  43. print("Necesitamos", res, "figus para completar")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement