def nice_indices(arr):
<EOL>ids = collections.defaultdict(count().__next__)<EOL>for idx,x in enumerate(arr):<EOL><INDENT>arr[idx] = ids[x]<EOL><DEDENT>return arr<EOL>
takes an array like [1,1,5,5,5,999,1,1]
and maps to something like [0,0,1,1,1,2,0,0]
modifies original in place as well as returns a ref