[TP4] Question 4 présumée finie
This commit is contained in:
parent
4ba3b96f1c
commit
52466839de
20
TP4/main.py
20
TP4/main.py
@ -32,7 +32,9 @@ def frequences(t0):
|
||||
# 6:
|
||||
|
||||
def graphe_frequences(t0):
|
||||
plt.plot(list(range(1, 27)), frequences(t0), 'ro')
|
||||
#plt.plot(list(range(1, 27)), frequences(t0), 'ro')
|
||||
for i, j in enumerate(t0):
|
||||
plt.bar(i+1, j)
|
||||
plt.ylabel('fréquences')
|
||||
plt.xlabel('lettres')
|
||||
plt.show()
|
||||
@ -76,3 +78,19 @@ def pgcd(a, b):
|
||||
return a
|
||||
|
||||
# 4:
|
||||
|
||||
def pgcdDesDistancesEntreRepetitions(l, i):
|
||||
ecarts=[]
|
||||
sec=l[i:i+3]
|
||||
g=i
|
||||
for j in range(g+1, len(l)-2):
|
||||
if sec==l[j:j+3]:
|
||||
ecarts.append(j-g)
|
||||
g=j
|
||||
print(ecarts)
|
||||
while len(ecarts)>1:
|
||||
ecarts[0]=pgcd(ecarts.pop(0), ecarts[0])
|
||||
if ecarts:
|
||||
return ecarts[0]
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user