message: Update count-all-possible-routes.py
diff: @@ -25,12 +25,20 @@ class Solution(object):
  for j in xrange(len(locations)-1):
  d = locations[j+1]-locations[j]
  if f > d:
  + # left[j][f] = right[j+1][f-d(j, j+1)] + 2*right[j+2][f-d(j, j+2)] + ... + 2^(k-1)*right[j+k][f-d(j, j+k)]
  + # => left[j+1][f] = (ight[j+2][f-d(j+1, j+2)] + 2*right[j+3][f-d(j+1, j+3)] + ... + 2^(k-2)*right[j+1+k-1][f-d(j+1, j+1+k-1)]
  + # => left[j+1][f-d(j, j+1)] = right[j+2][f-d(j, j+2)] + 2*right[j+3][f-d(j, j+3)] + ... + 2^(k-2)*right[j+k][f-d(j, j+k)]
  + # => left[j][f] = right[j+1][f-d(j, j+1)] + 2*left[j+1][f-d(j, j+1)]
  left[j][f] = (right[j+1][f-d] + 2*left[j+1][f-d] % MOD) % MOD;
  elif f == d:
  left[j][f] = int(j+1 == start)
  for j in xrange(1, len(locations)):
  d = locations[j]-locations[j-1]
  if f > d:
  + # right[j][f] = left[j-1][f-d(j, j-1)] + 2*left[j-2][f-d(j, j-2)] + ... + 2^(k-1)*left[j-k][f-d(j, j-k)]
  + # => right[j-1][f] = left[j-2][f-d(j-1, j-2)] + 2*left[j-3][f-d(j-1, j-3)] + ... + 2^(k-2)*left[j-1-k+1][f-d(j-1, j-1-k+1)]
  + # => right[j-1][f-d(j, j-1)] = left[j-2][f-d(j, j-2)] + 2*left[j-3][f-d(j, j-3)] + ... + 2^(k-2)*left[j-k][f-d(j, j-k)]
  + # => right[j][f] = left[j-1][f-d(j, j-1)] + 2*right[j-1][f-d(j, j-1)]
  right[j][f] = (left[j-1][f-d] + 2*right[j-1][f-d] % MOD) % MOD
  elif f == d:
  right[j][f] = int(j-1 == start)
  