Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Zip of course solution in Clear category for The Highest Building by Kolia951
def highest_building(buildings):
houses_stat = {}
for number, building in enumerate(zip(*buildings)):
houses_stat[number+1] = sum(building)
result = max(houses_stat.items(), key=lambda x: x[1])
return list(result)
if __name__ == "__main__":
print("Example:")
print(highest_building([[0, 0, 1, 0], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]]))
# These "asserts" using only for self-checking and not necessary for auto-testing
assert highest_building(
[[0, 0, 1, 0], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]]
) == [3, 4], "Common"
assert highest_building(
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]
) == [4, 1], "Cabin in the wood"
assert highest_building(
[
[1, 0, 0, 0, 0],
[1, 1, 0, 0, 0],
[1, 1, 1, 0, 0],
[1, 1, 1, 1, 0],
[1, 1, 1, 1, 1],
]
) == [1, 5], "Triangle"
assert highest_building(
[
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1],
]
) == [4, 6], "Pyramid"
print("Coding complete? Click 'Check' to earn cool rewards!")
Feb. 17, 2023
Comments: