מישהו פתר את זה? אני מגיע קרוב אבל תמיד האיבר האחרון נספר לי פעמיים (אם מחזירים 0 בשורה השנייה זה מסתדר)
מצטרף פה את הקוד:
def jump (lst): cnt = lst [len(lst)] + sum ([i for i in lst if i < 0]) return cnt def jump_limited (lst, max_jump): return jump_limited_rec(lst, max_jump, 0) def jump_limited_rec(lst, max_jump, ind): if ind == len(lst)-1: return lst[ind] cnt = float (99999999999999999999) for j in range(ind+1, ind+max_jump+1): if j < len(lst): res = lst[j] + jump_limited_rec(lst, max_jump, j) if res < cnt: cnt = res return cnt
תודה