Sunday, October 25, 2015

Lab6 - Find index of the floor(s) with maximum number of chairs (in the building)

def setup():
    floor1=[50,49,48,49,46,52,52]
    floor2=[49,51,50,52,47,48,47]
    floor3=[46,47,48,49,50,65,72]
    building=[floor1,floor2,floor3]
    find_chairs(building)

def find_chairs(building):
    iFloor=0
    total=0
    ref=0
    while(iFloor < len(building)):
        iRoom=0
        while(iRoom < len(building[iFloor])):
            total+=building[iFloor][iRoom]
            iRoom+=1
        if(total > ref):
            ref = total
            iMax = iFloor
        iFloor+=1
    print("Index of floor with maximum chairs is ",iMax)

setup()

No comments:

Post a Comment