top of page

CCC 2018 J2: Occupy parking


Simple if statement nested in a for loop that adds 1 to a variable (Occup) if they are both occupied (equal the char C). k is the number of spaces and day1/day2 are the parking spots for their respective days.


def compare(a,b,c):
    Occup = 0
    for i in range(c):
        if(a[i] == 'C' and a[i] == b[i]):
            Occup+=1
    print(Occup)

k = int(input())
day1 = input()
day2 = input()

compare(day1,day2,k)

Recent Posts

See All

Comments


bottom of page