diff --git a/homeworks/07_Danail_Bozhkov/Howework1.py b/homeworks/07_Danail_Bozhkov/Howework1.py new file mode 100644 index 0000000..254c6d0 --- /dev/null +++ b/homeworks/07_Danail_Bozhkov/Howework1.py @@ -0,0 +1,31 @@ +from math import sqrt + +def check_circles(centre1, radius1, centre2, radius2): + + if(centre1 == centre2 and radius1 == radius2): + return "Matching" + + x1, y1 = centre1 + x2, y2 = centre2 + distance = sqrt((x2 - x1)**2 + (y2 - y1)**2) + radius_sum = radius1 + radius2 + + if(distance == radius_sum): + return "Touching" + + if(distance < radius1 or distance < radius2): + return "Containing" + + if(distance < radius_sum): + return "Intercecting" + + if(distance > radius1 + radius2): + return "No comman" + + +c1 = (1,1) +c2 = (-5, 6) +c1_rad = 1 +c2_rad = 1 + +check_circles(c1,c1_rad,c2,c2_rad) diff --git a/homeworks/07_Danail_Bozhkov/hw_replace.py b/homeworks/07_Danail_Bozhkov/hw_replace.py new file mode 100644 index 0000000..3ca8fe8 --- /dev/null +++ b/homeworks/07_Danail_Bozhkov/hw_replace.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) diff --git a/homeworks/07_Danail_Bozhkov/num_ways.py b/homeworks/07_Danail_Bozhkov/num_ways.py new file mode 100644 index 0000000..11fde88 --- /dev/null +++ b/homeworks/07_Danail_Bozhkov/num_ways.py @@ -0,0 +1,19 @@ +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)))