initial commit
This commit is contained in:
commit
39f56a3b10
83 files changed
+3583
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import time
|
||||
|
||||
|
||||
def _min(lst: list, previous = None):
|
||||
if previous is None:
|
||||
previous = lst[0]
|
||||
for item in lst:
|
||||
previous = min(previous, item)
|
||||
return previous
|
||||
|
||||
def _max(lst: list, previous = None):
|
||||
if previous is None:
|
||||
previous = lst[0]
|
||||
for item in lst:
|
||||
previous = max(previous, item)
|
||||
return previous
|
||||
|
||||
def _avg(lst: list, total = 0):
|
||||
for item in lst:
|
||||
total += item
|
||||
return total / len(lst)
|
||||
|
||||
def main():
|
||||
i_lst = [5, 55, 2, 7, 45, 3, 1, 8, 23, 12]
|
||||
start = time.time()
|
||||
|
||||
for _ in range(100000):
|
||||
_min(i_lst)
|
||||
|
||||
end = time.time()
|
||||
print(end - start)
|
||||
print(_max(i_lst))
|
||||
print(_avg(i_lst))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,14 @@
|
||||
def calc_prime(n: int, d = 2):
|
||||
if n % d == 0:
|
||||
return d
|
||||
else:
|
||||
d += 1
|
||||
calc_prime(n, d)
|
||||
return False
|
||||
|
||||
def power_calc(n: int):
|
||||
p = calc_prime(n)
|
||||
#print(f"{p}^{n/p}")
|
||||
print(f"{n}/{p}")
|
||||
|
||||
power_calc(81)
|
||||
@@ -0,0 +1,16 @@
|
||||
def fibitts(s_population: list, months: int, previous = None):
|
||||
#every 2 months: 1 pair -> 2 pairs
|
||||
#newborn pair can produce a new pair only after 2 months
|
||||
|
||||
if previous is None:
|
||||
previous = s_population[0]
|
||||
|
||||
for month in range(months+1):
|
||||
if month == 0:
|
||||
pass
|
||||
else:
|
||||
s_population.append(s_population[month]+previous)
|
||||
print(f"Month {month}: {s_population[month]}")
|
||||
previous = s_population[month]
|
||||
|
||||
fibitts([1,1], 24)
|
||||
Reference in new issue
Block a user