Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. def get_lower_resolution(elevation_map: List[List[int]]) -> List[List[int]]:
  2. '''Return a new elevation map, which is constructed from the values
  3. of elevation_map by decreasing the number of points within it.
  4.  
  5. Precondition: elevation_map is a valid elevation map.
  6.  
  7. >>> get_lower_resolution(
  8. ... [[1, 6, 5, 6],
  9. ... [2, 5, 6, 8],
  10. ... [7, 2, 8, 1],
  11. ... [4, 4, 7, 3]])
  12. [[3, 6], [4, 4]]
  13. >>> get_lower_resolution(
  14. ... [[7, 9, 1],
  15. ... [4, 2, 1],
  16. ... [3, 2, 3]])
  17. [[5, 1], [2, 3]]
  18. '''
  19. newmap = []
  20.  
  21. m = elevation_map
  22. for i in range(0, len(elevation_map)-1, 2):
  23. newmap.append([])
  24. for j in range(0, len(elevation_map[i]), 2):
  25. if len(elevation_map) % 2 == 0:
  26. s = m[i][j]
  27. s += m[i][j+1]
  28. s += +m[i+1][j]
  29. s += m[i+1][j+1]
  30. newmap[-1].append(int(s/4))
  31. else:
  32.  
  33. s = elevation_map[i][j]
  34. s += elevation_map[i+1][j]
  35. newmap[-1].append(int(s/2))
  36.  
  37. if in_matrix(elevation_map,[i,j+1]):
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. return newmap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement