Advertisement
DianaP

Untitled

Jun 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #RICORSIONE: Si definisca una funzione ricorsiva che, data una lista L, un valore V e un intero k, restituisce true se il valore V è #presente in tutte le posizioni della lista il cui indice è multiplo di k, e false altrimenti.
  2.  
  3. def findV(L,v,k):
  4. # @param L: list;
  5. # @param v: T
  6. # @param k. int;
  7. # @return bool
  8.    if len(L)==0:
  9.       return false
  10.    elif len(L)<k:
  11.       return true
  12.    else:
  13.       return L[0]==v and findV(L[k:],v,k)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement