def find_position(someset, n, in_binary=False):
  """
  Computes the rank of a given subset `someset` of {1, 2, ..., `n`}
  in the lexicographical order. If `in_binary` is true, assumes that 
  `someset` is given as a characteristic vector.
  """
  if(in_binary):
    someset = [k for k in range(1, n + 1) if someset[k - 1]]
  return sum(2**(n - k) for k in someset) + 1