

from __future__ import annotations

def 		UpperCamelCase      (lowercase_:				str					,   lowercase_:				list[str] | None = None      )  ->   list[list[str]]:
	A__							:					Dict       =	word_bank or []
	# create a table
	A__							:					int       =	len(lowercase_      ) + 1

	A__							:					list[list[list[str]]]       =	[]
	for _ in range(lowercase_      ):
		table.append([]      )
	# seed value
	A__							:					Optional[Any]       =	[[]]  # because empty string has empty combination

	# iterate through the indices
	for i in range(lowercase_      ):
		# condition
		if table[i] != []:
			for word in word_bank:
				# slice condition
				if target[i : i + len(lowercase_      )] == word:
					A__							:					list[list[str]]       =	[
					    [word, *way] for way in table[i]
					]
					# adds the word to every combination the current position holds
					# now,push that combination to the table[i+len(word)]
					table[i + len(lowercase_      )] += new_combinations

    # combinations are in reverse order so reverse for better output
	for combination in table[len(lowercase_      )]:
		combination.reverse()

	return table[len(lowercase_      )]


if __name__ == "__main__":
	print(all_construct('jwajalapa', ['jwa', 'j', 'w', 'a', 'la', 'lapa']))
	print(all_construct('rajamati', ['s', 'raj', 'amat', 'raja', 'ma', 'i', 't']))
	print(
	    all_construct(
	        'hexagonosaurus',
	        ['h', 'ex', 'hex', 'ag', 'ago', 'ru', 'auru', 'rus', 'go', 'no', 'o', 's'],
	    )
	)






class 					_a		:


					'''simple docstring'''






					def __init__(				self    ):
						A__							:					str       =	""""""
						A__							:					Any       =	""""""
						A__							:					List[Any]       =	[]






					def 						__A    (				self					, A__					, A__    ):
						if m == -1:
							return n + 1
						elif n == -1:
							return m + 1
						elif self.dp[m][n] > -1:
							return self.dp[m][n]
						else:
							if self.worda[m] == self.worda[n]:
								A__							:					Optional[Any]       =	self.__min_dist_top_down_dp(m - 1					, n - 1    )
							else:
								A__							:					Union[str, Any]       =	self.__min_dist_top_down_dp(A__					, n - 1    )
								A__							:					Union[str, Any]       =	self.__min_dist_top_down_dp(m - 1					, A__    )
								A__							:					Union[str, Any]       =	self.__min_dist_top_down_dp(m - 1					, n - 1    )
								A__							:					List[Any]       =	1 + min(A__					, A__					, A__    )

							return self.dp[m][n]






					def 						__A    (				self					, A__					, A__    ):
						A__							:					Tuple       =	worda
						A__							:					Dict       =	worda
						A__							:					Optional[Any]       =	[[-1 for _ in range(len(A__    )    )] for _ in range(len(A__    )    )]

						return self.__min_dist_top_down_dp(len(A__    ) - 1					, len(A__    ) - 1    )






					def 						__A    (				self					, A__					, A__    ):
						A__							:					Optional[Any]       =	worda
						A__							:					Dict       =	worda
						A__							:					Union[str, Any]       =	len(A__    )
						A__							:					List[str]       =	len(A__    )
						A__							:					int       =	[[0 for _ in range(n + 1    )] for _ in range(m + 1    )]

						for i in range(m + 1    ):
							for j in range(n + 1    ):
								if i == 0:  # first string is empty
									A__							:					Tuple       =	j
								elif j == 0:  # second string is empty
									A__							:					Dict       =	i
								elif worda[i - 1] == worda[j - 1]:  # last characters are equal
									A__							:					str       =	self.dp[i - 1][j - 1]
								else:
									A__							:					Union[str, Any]       =	self.dp[i][j - 1]
									A__							:					str       =	self.dp[i - 1][j]
									A__							:					Union[str, Any]       =	self.dp[i - 1][j - 1]
									A__							:					Tuple       =	1 + min(A__					, A__					, A__    )
						return self.dp[m][n]


if __name__ == "__main__":
	A_ :				Union[str, Any]						 =    EditDistance()

	print('****************** Testing Edit Distance DP Algorithm ******************')
	print()

	A_ :				int						 =    input('Enter the first string: ').strip()
	A_ :				List[str]						 =    input('Enter the second string: ').strip()

	print()
	print(f'''The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}''')
	print(f'''The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}''')
	print()
	print('*************** End of Testing Edit Distance DP Algorithm ***************')



