Advertisement
Guest User

Ég Elska Forritun 1 - Python

a guest
Feb 13th, 2011
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. Mem = {}
  2.  
  3. def Poss(x, y):
  4.     if x == 100 and y == 100:
  5.         return 1
  6.  
  7.     k = str(x) + "," + str(y) if x > y else str(y) + "," + str(x)
  8.     if k in Mem:
  9.         return Mem[k]
  10.  
  11.     n = 0
  12.     if x <= 99 and y <= 99:
  13.         n += Poss(x + 1, y + 1)
  14.     if x <= 99:
  15.         n += Poss(x + 1, y)
  16.     if y <= 99:
  17.         n += Poss(x, y + 1)
  18.  
  19.     Mem[k] = n
  20.     return n
  21.  
  22. print(Poss(0, 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement