Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def path(T,s,current):
- return find_path(T,s,current,0)
- def find_path(T,s,current,count):
- for element in T:
- if element[1] == current:
- if element[0] == s:
- return count + 1
- else:
- return find_path(T,s,element[0],count + 1)
- return -1
- def check_connection_k(T,s,d,k):
- numero_salti = path(T,s,d)
- if numero_salti == -1:
- return False
- if numero_salti <= k:
- return True
- return False
- T = [[0,1],[1,3],[3,6],[6,8],[8,10]]
- print(check_connection_k(T,0,10,5))
Advertisement
Add Comment
Please, Sign In to add comment