[ Updated answer ] I made this code below that walks through a variable of X positions X times, that is, a variable of 5 positions is analyzed 25 times and at each time it checks the heading[1,2,3,4,5] until the position[1,2,3,4,5] + the quantity that the analysis is being repeated. That’s basically it:
a = "12345"
analisado | Quantidade de análise
1,2,3,4,5 | 1
12,23,34,45 | 2
123,234,345 | 3
1234,2345 | 4
12345 | 5
That way he’ll analyze the whole set of A, then just use one:
if (analysed in b):
'''script que verifica quais elementos de A estão contidos em B '''
a = "0000000724050613"
b = "07240001980055060113"
x=1
loop = len(a)
while loop>=x:
y=1
while loop>=y:
if y-1+x>loop:
y=loop
else:
sequencia = a[y-1:y-1+x]
if (sequencia in b):
print("A sequência {} está contida em b".format(sequencia))
y=y+1
x=x+1
I put it in my Github: https://github.com/gabriel-gregorio-da-silva/estaContidoEmB
This script has no filters, so if the number 7230 is contained in the B, it will show the 7,2,3 and 0 that are contained in the first analysis, then the 72,23 and 30 that are contained in the second analysis, then the 723,230 in the third analysis and then the 7230 in the fourth analysis.
You can build a filter logic, you take the values in each analysis and check if they are contained in the following analysis the 7, 2, 3 and 0 for example are contained in the second analysis as 73, 23 and 30, ie they would already be eliminated.
Ai in the third analysis, the 73, 23 and 30 would be eliminated, since they are in the third as 723 and 230.
In the fourth analysis, the 723 and the 230 would be eliminated because they are contained as 7230.
But they also have
13
,000
,07240
, and several digits in common. What defines this similarity? Does it have to be a three-digit sequence? The largest possible sequence? It has to be different from 0?– Andre
It could be the largest possible sequence. For example: 07240, 000 and 506. Check whether these 3 sequences in a also occur in b.
– Antonio Braz Finizola