Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = [[2,2,2,2,1],
- [3,3,1,2,2],
- [3,3,1,2,2],
- [2,2,2,2,2]]
- def threeMatriceRow(grl):
- match = False
- marked = []
- for i in range(len(grl)):
- for j in range(len(grl[0])-1):
- if(match == False):
- if(grl[i][j] == grl[i][j+1]):
- match = True
- first = True
- elif(grl[i][j] == grl[i][j+1]):
- if(first == True):
- marked.append((i,j-1))
- marked.append((i,j))
- marked.append((i,j+1))
- first = False
- else:
- marked.append((i,j+1))
- else:
- match = False
- match = False
- print(marked)
- This is the problematic function that gives me bad list of marked elements in column:
- def threeMatriceColumn(grl):
- match = False
- marked = []
- for i in range(len(grl)-1):
- for j in range(len(grl[0])):
- if(match == False):
- if(grl[i][j] == grl[i+1][j]):
- match = True
- first = True
- elif(grl[i][j] == grl[i+1][j]):
- if(first == True):
- marked.append((i-1,j))
- marked.append((i,j))
- marked.append((i-1,j))
- first = False
- else:
- marked.append((i+1,j))
- else:
- match = False
- match = False
- print(marked)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement