1: def matrix(m,n): if m == 1: return n+1 if n == 1: return m+1 else: return matrix(m,n-1)+matrix(m-1,n)
02: def getWayNum(n): def do(l): rel=[] length=len(l) for i in range(length+1): if i==length-1: rel.append(l[i]) elif i==length: rel.append((reduce(lambda x,y:x+y,rel))*2) else: rel.append((reduce(lambda x,y:x+y,l[:i+1]))) return rel l=[1] for i in range(1,n+1): l=do(l) return l[n]
def waynum(n): listy=[i for i in xrange(1,n+2)] for i in xrange(1,n): for j in xrange(1,n+1): listy[j]=listy[j-1]+listy[j] print listy[n]