Permutation Game Hackerrank Solution Python