diff --git a/homeworks/23_Plamen_Tsokov/checkCircles.py b/homeworks/23_Plamen_Tsokov/checkCircles.py new file mode 100644 index 0000000..b884221 --- /dev/null +++ b/homeworks/23_Plamen_Tsokov/checkCircles.py @@ -0,0 +1,27 @@ +from math import sqrt + +def check_Circles(c1_c, c1_r, c2_c, c2_r): + if(c1_c == c2_c and c1_r == c2_r): + return "Matching" + c1_x, c1_y = c1_c + c2_x, c2_y = c2_c + + distance = sqrt((c2_y - c1_y)**2 + (c2_x - c1_x)**2) + + if(c1_r + c2_ < distance): + return "not intersecting" + if(c1_r + c2_r == distance): + return "touching" + if(c1_r + c2_r > distance): + if(distance + c1_r <= c2_r): + if(c1_r + distance == c2_r): + return "Circle B contains circle A and they are touching" + else: + return "Circle B contains circle A" + elif(distance + c2_r <= c1_r): + if(c1_r == c2_r + distance): + return "Circle A contains circle B and they are touching" + else: + return "Circle A contains circle B" + else: + return "Intersecting" diff --git a/homeworks/23_Plamen_Tsokov/replace.py b/homeworks/23_Plamen_Tsokov/replace.py new file mode 100644 index 0000000..a353865 --- /dev/null +++ b/homeworks/23_Plamen_Tsokov/replace.py @@ -0,0 +1,16 @@ +#zadacha 3# +def replace(list, find, replace1): + a = 0 + for i in list: + if (type(i) != int) and (len(i) > 1): + list2 = list[a] + replace(list2, find, replace1) + if i == find: + list[a] = replace1 + a = a +1 + return list + +list = [ 'a', 1, [ ['a', 'b'], 1], ([1, 3, 'a'], 'b')] +res = replace(list, 'a', 'c') +print(res) # => [ 'c', 1, [ ['c', 'b'], 1], ([1, 3, 'c'], 'b')] + diff --git a/homeworks/23_Plamen_Tsokov/stairclimb.py b/homeworks/23_Plamen_Tsokov/stairclimb.py new file mode 100644 index 0000000..48e2676 --- /dev/null +++ b/homeworks/23_Plamen_Tsokov/stairclimb.py @@ -0,0 +1,13 @@ +#zadacha 2# +while True: + N = int(input("stair count: ")) + if N >= 2: + break + +def num_ways(N): + if N < 2: + return 1 + return num_ways(N-1) + num_ways(N-2) + +print(num_ways(N)) +