Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def odd_even_sums(tup):
- d = {}
- def odd_even_sum(tup):
- if len(tup) == 0:
- return tup + (0,0)
- elif len(tup) == 1:
- return tup + (0,)
- elif len(tup) == 2:
- return tup
- else:
- if tup in d:
- return d[tup]
- else:
- d[tup] = (tup[0] + odd_even_sum(tup[2:])[0], tup[1] + odd_even_sum(tup[2:])[1])
- return d[tup]
- if tup in d:
- return d[tup]
- else:
- d[tup] = odd_even_sum(tup)
- return d[tup]
- a=1
- tup=()
- while (a<10):
- tup += (a,)
- a+=1
- print(tup)
- input()
- print(odd_even_sums(tup))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement