Skip to content

A2x - Extensions

We are going to look at some problems from the Canadian Computing Competition. There is a junior and senior level. We'll focus on the junior. There are five questions in each competition. The first one is easy, the second is moderate, the third is difficult, and the fourth and fifth are very difficult.

Here are some example from the 2025 Junior competition:

Question 1

See Question Here

Answer
n = int(input())
c = int(input())
p = int(input())

capacity = c * p

if n > capacity:
    print("no")
else:
    print("yes")

Question 2

See Question Here

Answer
num_donuts = int(input())  # D
num_events = int(input())  # E

for i in range(num_events):
    event_type = input()
    amount = int(input())

    if event_type == "+":
        num_donuts += amount
    else:
        num_donuts -= amount

print(num_donuts)

Your Task

First, try questions 1 and 2 from the 2024 junior competition, found here.

Then, give question 3 a try from the 2025 junior competition, found here. Here is some starter code for this one, which just does the easy part (keeping uppercase letters, getting rid of lowercase letters). The rest is quite tough, but later on I will go through a good strategy once many of you have had a chance to give it a try.

n = int(input())

for i in range(n):

    old_code = input()
    new_code = ""

    for char in old_code:

            if char.islower():
                continue

            if char.isupper():
                new_code += char
                continue



    # Here we are at the end of a product code
    print(new_code)