Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- person = int(input())
- def get_commits(person, dict={}):
- # print(f'Starting with {person}')
- if person == 0:
- return 1
- elif person == 1:
- return 1
- elif person > 1:
- # print(f'Get person {person - 1} and {person - 2}')
- if person not in dict:
- first = get_commits(person - 2, dict)
- dict[person - 2] = first
- second = get_commits(person - 1)
- dict[person - 1] = second
- sum = first + second
- dict[person] = sum
- else:
- sum = dict[person]
- return sum
- print(get_commits(person))
Advertisement
Add Comment
Please, Sign In to add comment