def indexFromCoordinates(coordinates, dimensions):
 index = 0
 for (i, dimension) in enumerate(dimensions):
  index *= dimension
  index += coordinates[i]
 return index

def indexFromCoordinates ( coordinates , dimensions ) : index = 0 for ( i , dimension ) in enumerate ( dimensions ) : index *= dimension index += coordinates [ i ] return index
translate coordinates into an index .