Advertisement
igort91

control toptoptop

Dec 9th, 2011
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. from numpy import array,shape
  2. def sala_mas_concurrida(cine):
  3.     x,y=cine.shape
  4.     max=-float("inf")
  5.     cine_mas_concurrido=""
  6.     for columna in range(y): #itera por columna
  7.         acum=0               #acumula la suma de los true (que es de 1 c/u)
  8.         for fila in range(x): #itera por final
  9.             acum+=cine[fila][columna] #suma los true
  10.         if acum>max:
  11.             cine_mas_concurrido=columna
  12.             max=acum
  13.     return cine_mas_concurrido
  14.  
  15. cine=array([[1,1,0,1,1],
  16.             [1,1,1,1,1],
  17.             [0,0,1,0,0],
  18.             [1,0,1,1,0],
  19.             [0,1,1,0,0],
  20.             [1,0,1,0,1],
  21.             [0,0,1,1,0],
  22.             [0,1,1,0,1],
  23.             [1,0,1,1,0],
  24.             [0,1,1,0,1]])
  25.  
  26. print sala_mas_concurrida(cine)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement