davegimo

Untitled

Jul 7th, 2020
1,334
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def cammino(T,s,d):
  2.     if T[d-1][1] == s:
  3.         return [s]
  4.     else:
  5.         l = []
  6.         l.append(d)
  7.         l.extend(cammino(T,s,T[d-1][1]))
  8.         return l
  9.  
  10.  
  11. def distanza(T,s,d):
  12.     if T[d-1][1] == s:
  13.         return T[d-1][2]
  14.     return T[d-1][2] + distanza(T,s,T[d-1][1])
  15.  
  16.  
  17. p = [[1, 0, 1], [2, 0, 1], [3, 2, 1], [4, 3, 1], [5, 3, 1], [6, 4, 1], [7, 5, 1]]
RAW Paste Data