Check neighbor in an array

0

I have the following problem:

I have a large array [10x10 for example] It has values from 1 to 9.

I should check if a vector [1, 2, 3, 4, 5] (for example) is contained in this array. When I find the first number of the vector inside the array, I should check the neighbors. But, if the number 1 is in the middle of the array, I have to check the 8-number environment. How do I do this reading? If anybody can explain me, can you try to do as silly as possible while using?

The functions below are not complete:

def ProcuraPrimeiroNumero(retang, padrao, i, j):
    '''Esta função procura o primeiro numero na matriz'''


    while i<num_lin: #procurando o 1º numero a partir da primeira linha
        while j<num_col: #procurando o 1º numero a partir da primeira coluna
            if retang[i][j] == padrao[0]: #Se o primeiro numero do vetor for igual ao primeiro numero da matriz
                VerificaSeCabe (retang, t, direçao, i, j)
                if VerificaSeCabe == 1:

def VerificaSeCabe(retang, direçao, t, i, j):
    k = 1
    l = 1
    aux_mat =[]
    x = 0
    y = 0
    while x<num_lin:
        lin = []
        y = 0
        while y<num_col:
            lin=lin+[0]
            y=y+1
        aux_mat = aux_mat +[lin]
        x=x+1
    while k<=4: #contador para as direções
        while l<=4: #contador para as direções
            if ((x+t-1)<=i-x):
                if (y+t-1<=j-1):
                    cabe = 1
                else:
                    cabe = -1
    
asked by anonymous 08.12.2017 / 03:10

0 answers