"Convert list of positions [4, 1, 2] of arbitrary length to an index for a nested list","from functools import reduce