Smallest missing positive

Write first_missing(nums) that returns the smallest positive whole number not in the list. The classic version uses the list itself as the hash table so that extra memory is constant; a set also passes.

first_missing([1, 2, 0])      ->  3
first_missing([3, 4, -1, 1])  ->  2
first_missing([7, 8, 9])      ->  1

The answer is between 1 and len + 1. Put each value v in that range at index v - 1 by swapping, then scan for the first index whose value is wrong.

def first_missing(nums):
    ...