Advertisement
Guest User

game

a guest
Feb 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. a = [[2,2,2,2,1],
  2. [3,3,1,2,2],
  3. [3,3,1,2,2],
  4. [2,2,2,2,2]]
  5.  
  6. def threeMatriceRow(grl):
  7. match = False
  8. marked = []
  9. for i in range(len(grl)):
  10. for j in range(len(grl[0])-1):
  11. if(match == False):
  12. if(grl[i][j] == grl[i][j+1]):
  13. match = True
  14. first = True
  15. elif(grl[i][j] == grl[i][j+1]):
  16. if(first == True):
  17. marked.append((i,j-1))
  18. marked.append((i,j))
  19. marked.append((i,j+1))
  20. first = False
  21. else:
  22. marked.append((i,j+1))
  23. else:
  24. match = False
  25. match = False
  26. print(marked)
  27.  
  28.  
  29.  
  30. This is the problematic function that gives me bad list of marked elements in column:
  31.  
  32. def threeMatriceColumn(grl):
  33. match = False
  34. marked = []
  35. for i in range(len(grl)-1):
  36. for j in range(len(grl[0])):
  37. if(match == False):
  38. if(grl[i][j] == grl[i+1][j]):
  39. match = True
  40. first = True
  41. elif(grl[i][j] == grl[i+1][j]):
  42. if(first == True):
  43. marked.append((i-1,j))
  44. marked.append((i,j))
  45. marked.append((i-1,j))
  46. first = False
  47. else:
  48. marked.append((i+1,j))
  49. else:
  50. match = False
  51.  
  52. match = False
  53.  
  54. print(marked)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement