Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

finding the single-color row & column

NikaMsv (750 points)
2 11 17
in HW8 by (750 points)
recategorized by
Hello ! I'm looking for a faster solution to this problem could you please share it with me if you hyave an idea ?

We have an image (in the form of a matrix) divided by some axis-aligned lines (in the form of a +) in a way that it has splitted firstly into 4 pieces

then each of those 4 pieces could also be divided into 4 pieces themselves or not . And if they're divided , the splitter lines lie within those pieces (maximum length equals

 the length of the side of the specific rectangular piece) a new color is used in each level of sub-division.

The objective is to find the row index and column index of the splitter lines which divide the image in the first level .

My approach is to iterate over each index in the range(len(matrix)) which means through each row , turn it into a set, get the len() of it and if equal to 1 ,

assign it to row index .

Then get one of the items in that row and index it in the row above , so it tells us where the column crosses the row above . and then we have the column index as well

I'd really appreciate a faster or more efficient approach
222 views

Please log in or register to answer this question.