[Programación]Problema raro en if (): else: en python WTF???

Horacio Castellini horacio9573 en yahoo.com.ar
Jue Ago 23 13:41:44 ART 2012



Acá hice un segundo experiemento...  

A=[[0,1,0,0],[1,0,1,0],[0,1,0,1],[0,0,1,0]]

NR=4

#Evalua la lineas periodicas, busca la diag maxima
d=[]
d=[0]*NR
LM=0
for c in range(NR):
   s=0
   for x in range(NR):
       y=x+c
       if  y<NR :
           if A[x][y]==1 :
               s+=1
               print x,y,A[x][y],s
           else:
               print x,y,s,LM
               if  s>LM :
                   LM=s
               d[s]+=1
               s=0
print "Diagonal maxima %d" % LM

0 0 0 0
1 1 0 0
2 2 0 0
3 3 0 0
0 1 1 1
1 2 1 2
2 3 1 3
0 2 0 0
1 3 0 0
0 3 0 0
Diagonal maxima 0
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lugro.org.ar/pipermail/programacion/attachments/20120823/c2272057/attachment.htm>


Más información sobre la lista de distribución Programacion