# a function to create a random map as simulated input for testing:
def get_map(x_size, y_size, min_height, max_height):
    import random
    return [[random.randint(min_height, max_height) for x in range(x_size)] for y in range(y_size)]

# a function to nicely print the map for debug and visualization
def print_map(hmap):
    print(*hmap, sep="\n")
    

# calculate approximate land area where the height is greater than zero
# map is a list of lists, tile_size is in m², min_level is the sea level
def calc_land_area(hmap, tile_size=100, min_level=0):
    land_tiles = sum(len([tile for tile in row if tile>min_level]) for row in hmap)
    return tile_size * land_tiles


try:
	hmap = get_map(5, 5, 0, 3)
	print_map(hmap)
	print("land area:", calc_land_area(hmap), "m²")
except Exception as e:
	print(e)