Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve(sum):
- sum_left = sum
- func_h_r = []
- for i in range(1,sum_left):
- sum_left = sum_left - i
- func_h_r.append(i)
- if sum_left>=i:
- continue
- else:
- break
- h=len(func_h_r)
- while sum_left>0:
- i-=1
- sum_left=sum_left-i
- func_h_r.append(i)
- if sum_left==0:
- n_h_r=len(func_h_r)
- break
- elif sum_left<0:
- n_h_r=-1
- else:
- continue
- return print(func_h_r)
- solve(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement