diff --git a/homeworks/05_Vladimir_Aleksiev/rs.py b/homeworks/05_Vladimir_Aleksiev/rs.py new file mode 100644 index 0000000..53aef96 --- /dev/null +++ b/homeworks/05_Vladimir_Aleksiev/rs.py @@ -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) \ No newline at end of file diff --git a/homeworks/05_Vladimir_Aleksiev/zad2.py b/homeworks/05_Vladimir_Aleksiev/zad2.py new file mode 100644 index 0000000..5c2457b --- /dev/null +++ b/homeworks/05_Vladimir_Aleksiev/zad2.py @@ -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))) diff --git a/homeworks/05_Vladimir_Aleksiev/zad3.py b/homeworks/05_Vladimir_Aleksiev/zad3.py new file mode 100644 index 0000000..527a191 --- /dev/null +++ b/homeworks/05_Vladimir_Aleksiev/zad3.py @@ -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)