pre_merge_commit

This commit is contained in:
Suwako Moriya 2020-01-09 08:10:47 +01:00
parent 236bb61ec3
commit 35efbfdd5e
Signed by: SuwakoMmh
GPG Key ID: A27482B806F13CD5
3 changed files with 124 additions and 0 deletions

100
Cours/cours6.py Normal file
View File

@ -0,0 +1,100 @@
# Complexité
import numpy as np
def diviseurs1(n):
d = 0
k = 1
while k <= n:
if n % k == 0:
d += 1
k += 1
return d
def diviseurs2(n):
d = 0
k = 1
while k * k < n:
if n % k == 0:
d += 2
k += 1
if k * k == n:
d += 1
return d
#Instructions élémentaires
"""
Les opérations arithmétiques,
les comparaisons de données élémentaires ()
les transferts de données
les instructions de contrôle
sont considérés de coût constant (1)
En revanche, tester l'égalité de deux chaines de caractère n'est de coût
constant qu'en cas de tests un à un.
Aussi, la recopie d'un tableau n'est pas de coût constant.
Les coûts résonables :
logarithmique O(log(n))
linéaire O(n)
semi-linéaire O(nlog(n))
quadratique O()
"""
def f1(n):
x = 0
for i in range(n):
for j in range(n):
x += 1
return x
#O(n²)
def f2(n):
pass
def f4(n): # O(logn)
x, i = 0, n
while i > 1:
x += 1
i //= 2
return x
def f5(n): # O(nlog(n))
x, i = 0, n
while i > 1:
for j in range(n):
x += 1
i //= 2
return x
def f6(n):
x, i = 0, n
while i > 1:
for j in range(i) :
x += 1
i //= 2
return x
def cherche(x, l):
for y in l:
if y == x:
return True
return False
def cherche_dicho(x, l):
i, j = 0, len(l)
while i < j:
k = (i + j) // 2
if l[k] == x:
return True
elif l[k] > x:
j = k
else:
i = k + 1
return False

7
maths/Applications/exo10.py Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python3
def verifier(L, p, q):
return len(L)==p and min(L)>=0 and max(L) <= q - 1
def composer(L1, L2):
return [L2[i] for i in L1]
def permutation(L):

17
maths/Q Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 29 19:54:04 2019
@author: suwako
"""
def f(n, k=14):
return ((n+k)/(n))**(1/2)
def test(n, k=14):
L=[]
for i in range(1, n+1):
a=f(i, k)
if a == int(a):
L.append(i)
return L