Please provide the running code in Python 3
6d 22h left
3. People Per Floor
Language: Python 3
v Autocomplete Ready
?
:
#!/bin/python3
While taking a stroll through Madison Square Park, you look up at all the gorgeous buildings: the Flatiron, Met Life Tower, Eleven Madison. You begin to wonder about what people live and work there, so you go into each building and ask for the number of people currently there. Each gives you a list of the number of people currently in the building per floor. Given these lists of buildings, can you say which floor, across all buildings, has the most people?
10 11 12 Complete the 'mostPeoplePerFloor' function below
13 14 The function is expected to return an INTEGER
15 The function accepts a 2D_INTEGER_ARRAY 'people_per_floor' as a parameter
18 def mostPeoplePerFloor(people_per_floor):
20 if __name__ == '__main__':
21 fptr = open(os.environ['OUTPUT_PATH'], 'w')
23 people_per_floor_rows = int(input().strip())
24 people_per_floor_columns = int(input().strip())
26 people_per_floor = []
28 for _ in range(people_per_floor_rows):
29 people_per_floor.append(list(map(int, input().rstrip().split())))
31 result = mostPeoplePerFloor(people_per_floor)
33 fptr.write(str(result) + '\n')
35 fptr.close()
36
ALL
Break ties by using the higher floor
2
Example:
3
people_per_floor = [ [0,3,9,11], [2,4,8], [1,1,1,1,1], [7,7].
4
# Zero-th floor has 16 people, # First has 15, # Second has 18, # Third has 12, # Fourth has 1
mostPeoplePerFloor(people_per_floor) ==
Line: 19 Col: 5
Test Results
Custom Input
Run Code
Run Tests
Submit