def coordinatesFromIndex(index, dimensions):
 coordinates = ([0] * len(dimensions))
 shifted = index
 for i in xrange((len(dimensions) - 1), 0, (-1)):
  coordinates[i] = (shifted % dimensions[i])
  shifted = (shifted / dimensions[i])
 coordinates[0] = shifted
 return coordinates

def coordinatesFromIndex ( index , dimensions ) : coordinates = ( [ 0 ] * len ( dimensions ) ) shifted = index for i in xrange ( ( len ( dimensions ) - 1 ) , 0 , ( - 1 ) ) : coordinates [ i ] = ( shifted % dimensions [ i ] ) shifted = ( shifted / dimensions [ i ] ) coordinates [ 0 ] = shifted return coordinates
translate an index into coordinates .