Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add homeworks #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
31 changes: 31 additions & 0 deletions homeworks/07_Danail_Bozhkov/Howework1.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions homeworks/07_Danail_Bozhkov/hw_replace.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)
19 changes: 19 additions & 0 deletions homeworks/07_Danail_Bozhkov/num_ways.py
Original file line number Diff line number Diff line change
@@ -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)))