






'''simple docstring'''







def 		_UpperCAmelCase (				__A				: List[Any]   ):
				# if the collection is empty, returns empty
				if collection == []:
								return []

				# get some information about the collection
				a_		:	Tuple									=   len(__A   )
				a_		:	Union[str, Any]									=   max(__A   )
				a_		:	List[Any]									=   min(__A   )

				# create the counting array
				a_		:	List[Any]									=   coll_max + 1 - coll_min
				a_		:	Any									=   [0] * counting_arr_length

				# count how much a number appears in the collection
				for number in collection:
								counting_arr[number - coll_min] += 1

				# sum each position with it's predecessors. now, counting_arr[i] tells
				# us how many elements <= i has in the collection
				for i in range(1    ,		__A   ):
								a_		:	str									=   counting_arr[i] + counting_arr[i - 1]

				# create the output collection
				a_		:	Tuple									=   [0] * coll_len

				# place the elements in the output, respecting the original order (stable
				# sort) from end to begin, updating counting_arr
				for i in reversed(range(0    ,		__A   )   ):
								a_		:	int									=   collection[i]
								counting_arr[collection[i] - coll_min] -= 1

				return ordered





def 		_UpperCAmelCase (				__A				: Any   ):
				return "".join([chr(__A   ) for i in counting_sort([ord(__A   ) for c in string]   )]   )


if __name__ == "__main__":
		# Test string sort
		assert counting_sort_string('thisisthestring') == "eghhiiinrsssttt"

		__lowerCAmelCase									=   input('Enter numbers separated by a comma:\n').strip()
		__lowerCAmelCase									=   [int(item) for item in user_input.split(',')]
		print(counting_sort(unsorted))












'''simple docstring'''







from __future__ import annotations

from typing import TypedDict





class 						SCREAMING_SNAKE_CASE       (       SCREAMING_SNAKE_CASE_							):
			snake_case__	=					42
			snake_case__	=					42





def 		_UpperCAmelCase (				__A				: str   ):
				if not isinstance(__A    ,		__A   ):
								raise TypeError('''The parameter s type must be str.'''   )

				return [s[i:] + s[:i] for i in range(len(__A   )   )]





def 		_UpperCAmelCase (				__A				: str   ):
				if not isinstance(__A    ,		__A   ):
								raise TypeError('''The parameter s type must be str.'''   )
				if not s:
								raise ValueError('''The parameter s must not be empty.'''   )

				a_		:	str									=   all_rotations(__A   )
				rotations.sort()  # sort the list of rotations in alphabetically order
				# make a string composed of the last char of each rotation
				a_		:	BWTTransformDict									=   {
				    "bwt_string": "".join([word[-1] for word in rotations]   ),
				    "idx_original_string": rotations.index(__A   ),
				}
				return response





def 		_UpperCAmelCase (				__A				: str    ,		__A				: int   ):
				if not isinstance(__A    ,		__A   ):
								raise TypeError('''The parameter bwt_string type must be str.'''   )
				if not bwt_string:
								raise ValueError('''The parameter bwt_string must not be empty.'''   )
				try:
								a_		:	Union[str, Any]									=   int(__A   )
				except ValueError:
								raise TypeError(
								    '''The parameter idx_original_string type must be int or passive'''
								    ''' of cast to int.'''   )
				if idx_original_string < 0:
								raise ValueError('''The parameter idx_original_string must not be lower than 0.'''   )
				if idx_original_string >= len(__A   ):
								raise ValueError(
								    '''The parameter idx_original_string must be lower than''' ''' len(bwt_string).'''   )

				a_		:	Union[str, Any]									=   [''''''] * len(__A   )
				for _ in range(len(__A   )   ):
								for i in range(len(__A   )   ):
												a_		:	int									=   bwt_string[i] + ordered_rotations[i]
								ordered_rotations.sort()
				return ordered_rotations[idx_original_string]


if __name__ == "__main__":
		__lowerCAmelCase									=   'Provide a string that I will generate its BWT transform: '
		__lowerCAmelCase									=   input(entry_msg).strip()
		__lowerCAmelCase									=   bwt_transform(s)
		print(
		    F"""Burrows Wheeler transform for string '{s}' results """
		    F"""in '{result['bwt_string']}'"""
		)
		__lowerCAmelCase									=   reverse_bwt(result['bwt_string'], result['idx_original_string'])
		print(
		    F"""Reversing Burrows Wheeler transform for entry '{result['bwt_string']}' """
		    F"""we get original string '{original_string}'"""
		)




