n = 2 maxx = 100 path1 = range(1,10) path_1 = range(1,11) total = sum(path1) + sum(path_1) - 1 while n < maxx: new1 = [] new_1 = [] tmp1 = 0 tmp_1 = 0 for i in xrange(9): tmp1 += path1[i] new1.append(tmp1) path1 = new1 for i in xrange(10): tmp_1 += path_1[i] new_1.append(tmp_1) path_1 = new_1 # print path1, path_1 total += sum(path1) + sum(path_1) - 9 - 1 n += 1 print total