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

CCC '24 J5 - Harvest Waterloo

#include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <stack> using namespace std; int main() { int r, c,...

CCC '24 J4 - Troublesome Keys

s1 = input() s2 = input() silly = '' silly_o = '' quiete = '-' i = 0 j = 0 while i < len(s1) and j < len(s2): if s1[i] != s2[j]: if...

CCC '22 J5 - Square Pool

#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int,...

Comments


bottom of page