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
27 changes: 27 additions & 0 deletions homeworks/23_Plamen_Tsokov/checkCircles.py
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 16 additions & 0 deletions homeworks/23_Plamen_Tsokov/replace.py
Original file line number Diff line number Diff line change
@@ -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')]

13 changes: 13 additions & 0 deletions homeworks/23_Plamen_Tsokov/stairclimb.py
Original file line number Diff line number Diff line change
@@ -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))