:3

Everything is barely weeks. Everything is days. We have minutes to live.

My profile photo

DMOJ - Problem of the week #1 - Baker Brie - ecoo17r3p1

Posted

I’ve been having a lot of fun (and sometimes a lot of frustration haha) working through an excellent Python book Learn to code by Solving Problems by Daniel Zingaro.

Most of the practice is done through solving challenges on https://dmoj.ca/. I would like to share one challenge a week and my solution to it.

Currently I am working on improving my ability to work with lists and Challenge ecoo17r3p1 — Baker Brie was great practise.

The main challenge and lesson learned here was how to use the split method to work with input, as well as reviewing nested lists. For some reason nested lists can be a little difficult for me to visualise, but practice makes perfect!

Here is my code:

for dataset in range(10):
    lst = input().split()
    franchisees = int(lst[0])
    days = int(lst[1])
    grid = []

    for i in range(days):
        row = input().split()
        for j in range(franchisees):
            row[j] = int(row[j])
        grid.append(row)

    bonuses = 0

    for row in grid:
        total = sum(row)
        if total % 13 == 0:
            bonuses = bonuses + total // 13

    for col_index in range(franchisees):
        total = 0
        for row_index in range(days):
            total = total + grid[row_index][col_index]
        if total % 13 == 0:
            bonuses = bonuses + total // 13

    print(bonuses)

Author