Advertisement
Guest User

Zadanie 6.3

a guest
Aug 19th, 2018
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. filename='dane.txt'
  2. mylist=[]
  3. counter=0
  4. with open(filename) as file:
  5. for line in file:
  6. line=line.split(' ')
  7. for i in range(len(line)):
  8. line[i]=int(line[i])
  9. mylist.append(line)
  10. for i in range(200):
  11. for j in range(320):
  12. stop=0
  13. try:
  14. if mylist[i][j]-mylist[i+1][j]>128 or mylist[i][j]-mylist[i+1][j]<-128:
  15. counter=counter+1
  16. stop=1
  17. except:
  18. pass
  19. if stop==0:
  20. try:
  21. if mylist[i][j] - mylist[i-1][j] > 128 or mylist[i][j] - mylist[i - 1][j] < -128:
  22. counter = counter + 1
  23. stop = 1
  24. except:
  25. pass
  26. if stop==0:
  27. try:
  28. if mylist[i][j] - mylist[i][j+1] > 128 or mylist[i][j] - mylist[i][j+1] < -128:
  29. counter = counter + 1
  30. stop = 1
  31. except:
  32. pass
  33. if stop==0:
  34. try:
  35. if mylist[i][j] - mylist[i][j-1] > 128 or mylist[i][j] - mylist[i][j-1] < -128:
  36. counter = counter + 1
  37. stop = 1
  38. except:
  39. pass
  40.  
  41. print(counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement