Hello There is a task at one of the training sites. Here’s how it sounds - "Given a square matrix of size N x N. It is necessary to check if there is a sequence of 4 or more identical digits. The sequence must be inseparably arranged horizontally, vertically or along the diagonals (primary and secondary).
Input: The matrix, as a list (list) lists with integers.
Output: Is there a sequence, as a Boolean value (bool).
Examples:
checkio([ [1, 2, 1, 1], [1, 1, 4, 1], [1, 3, 1, 6], [1, 7, 2, 5] ]) == True Previously, I solved the matrix 3 by 3. they put the correct decisions in the list and checked in a cycle. How to solve similar problems with large matrices? Tell me please. You can write the answer, I will write it down in the notes and I will analyze (read-learn). You can cover tips.
I found here the same question, where one of the answers, from SW. Kromster, I explained the front of work, here it is:
1- learn to check if there are 4+ identical elements in a row in a simple list (if it does not work, ask a separate Stack Overflow question about this (and only about this)) 2- generate all rows, columns, diagonals and apply the check function for the list to each .