-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgoritmoFuerzaBruta.py
65 lines (39 loc) · 1.44 KB
/
algoritmoFuerzaBruta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def iniciar (algoritmo, byteInicial):
if algoritmo == 0:
buscarLorem(byteInicial)
elif algoritmo == 1:
KMP(byteInicial)
else:
print ("Revisar los datos ingresados")
def buscarLorem (byteInicial):
palabra = "Lorem"
texto = "Quiero Lorem enconLoremtrar la palabra perro Lorx solo una Lorem vez"
total = len(texto)
flagEncuentra = 0
#print (palabra [1:])
#print (palabra [0])
i = byteInicial
contador = 0
apariciones = 0
while total > i:
print (texto [i])
print ("llegué2")
if palabra [0] == texto [i]: # Aparición de la primera letra buscada
print ("llegué3")
while 5 > contador: #R5 > contador
if palabra [contador] == texto [i]:
print ("entré 1.2.1.2")
contador += 1
i += 1
else:
break
if contador == 5:
print ("palabra encontrada")
contador = 0
apariciones += 1
print ("llegué1")
else:
contador = 0
i += 1
print("Apariciones: ", apariciones)
iniciar (0, 0)