Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions homeworks/05_Vladimir_Aleksiev/rs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import math

def circle(c1,r1,c2,r2):

x=math.sqrt((c2[0] - c1[0])**2 + (c2[1] - c1[1])**2) - (r2 + r1)
if(x == 0):
print("tuching")
return

if((c2 == c1)and(r1==r2)):
print("matching")
return

if(r1>r2):
d= math.sqrt( (c2[0]-c1[0])**2 + (c2[1]-c1[1])**2 )
if(r1> d):
print("circle1 is containing circle2")
return
else:
e= math.sqrt( (c1[0]-c2[0])**2 + (c1[1]-c2[1])**2 )
if(r2>e):
print("circle2 is containing circle1")
return

if(x < 0):
print("intercepting")
return

if(x > 0):
print("NO Common")
print("the distance in px = ", x)
return



x=2
y=0
x1=2
y2=0
cx1=(x,y)
cx2=(x1,y2)
rx1=2
rx2=1
circle(cx1,rx1,cx2,rx2)
20 changes: 20 additions & 0 deletions homeworks/05_Vladimir_Aleksiev/zad2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

N = input("Enter how many stairs you will climb: ")

def num_ways(n):

if n < 0:
return 0

if n == 0:
return 1

nums = [0] * (n+1)
nums[0] = 1
nums[1] = 2

for i in range(1, n+1):
nums[i] = nums[i-1] + nums[i-2]
return nums[n]

print(num_ways(int(N)))
16 changes: 16 additions & 0 deletions homeworks/05_Vladimir_Aleksiev/zad3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import Any

def replace(element: Any, find: str, replace: str):
if element == find:
return replace

for i in range(len(element)):
if element[i] == find:
element[i] = replace

return element


list = [ 'a', 1, [ ['a', 'b'], 1], ([1, 3, 'a'], 'b')]
res = replace(list, 'a', 'c')
print(res)