Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
native_the_highest_building solution in Clear category for The Highest Building by Jon_Red
def highest_building(buildings):
return sorted([
[y+1,sum(x[y]for x in buildings)]for y in range(len(buildings))
],key=lambda x:x[-1])[-1]
if __name__ == '__main__':
# self-checks
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'
July 17, 2020