HackerRank "Manasa and Stones" in Python
Since a, b can be equal, I wrap this list into a set to produce my
  code below.


Why not just handle this case separately? It's then simple to prove that if a != b, we don't have repeated values, and we can just generate them in increasing order.

def last_stone(a, b, n):
    if a == b:
        return [a * (n - 1)]
    if a &lt; b:
        return last_stone(b, a, n)
    return [i * a + (n - i - 1) * b for i in range(n)]