

"""simple docstring"""




def 	UpperCAmelCase__   (				A__   )      ->      list[list[int]]:




   """simple docstring"""
   lowerCamelCase__						=			[]
   if len(A__   ) == 1:
      return [nums.copy()]
   for _ in range(len(A__   )   ):
      lowerCamelCase__						=			nums.pop(0   )
      lowerCamelCase__						=			permute(A__   )
      for perm in permutations:
         perm.append(A__   )
      result.extend(A__   )
      nums.append(A__   )
   return result



def 	UpperCAmelCase__   (				A__   )      ->      List[str]:




   """simple docstring"""

   def backtrack(A__   ):
      if start == len(A__   ) - 1:
         output.append(nums[:]   )
      else:
         for i in range(A__	,    len(A__   )   ):
            lowerCamelCase__					,       lowerCamelCase__						=			nums[i], nums[start]
            backtrack(start + 1   )
            lowerCamelCase__					,       lowerCamelCase__						=			nums[i], nums[start]  # backtrack

   lowerCamelCase__						=			[]
   backtrack(0   )
   return output


if __name__ == "__main__":
     import doctest

     # use res to print the data in permute2 function
     SCREAMING_SNAKE_CASE_     :			List[str]	  =			permutea([1, 2, 3])
     print(res)
     doctest.testmod()







"""simple docstring"""




# Algorithm for the pigeonhole sorting





def 	UpperCAmelCase__   (				A__   )      ->      Dict:




   """simple docstring"""
   lowerCamelCase__						=			min(A__   )  # min() finds the minimum value
   lowerCamelCase__						=			max(A__   )  # max() finds the maximum value

   lowerCamelCase__						=			max_val - min_val + 1  # size is difference of max and min values plus one

   # list of pigeonholes of size equal to the variable size
   lowerCamelCase__						=			[0] * size

   # Populate the pigeonholes.
   for x in a:
      assert isinstance(A__	,    A__   ), "integers only please"
      holes[x - min_val] += 1

   # Putting the elements back into the array in an order.
   lowerCamelCase__						=			0
   for count in range(A__   ):
      while holes[count] > 0:
         holes[count] -= 1
         lowerCamelCase__						=			count + min_val
         i += 1



def 	UpperCAmelCase__   (				)      ->      Optional[int]:




   """simple docstring"""
   lowerCamelCase__						=			[8, 3, 2, 7, 4, 6, 8]
   pigeonhole_sort(A__   )
   print("Sorted order is:"	,    " ".join(A__   )   )


if __name__ == "__main__":
     main()




