problem 24 i feel bad because i found this permutation algorithm