human
Maximum and minimum sums from two numbers with digit replacements | Find new value of x after replacing digit " from " to " to ".
Required digit found , replace it.
Returns maximum and minimum possible sums of x1 and x2 if digit replacements are allowed ..
We always get minimum sum if we replace 6 with 5..
We always get maximum sum if we replace 5 with 6..
Driver code"
How can the above be solved in Python?
 What is a code to maximum and minimum sums from two numbers with digit replacements and the other steps required?
assistant
#Here is code to maximum and minimum sums from two numbers with digit replacements and the other steps required.
 def replaceDig ( x , from1 , to ) :
	result = 0
	multiply = 1
	while ( x > 0 ) :
		reminder = x % 10
		if ( reminder == from1 ) :
			result = result + to * multiply
		else :
			result = result + reminder * multiply
		multiply *= 10
		x = int ( x / 10 )
	return result
def calculateMinMaxSum ( x1 , x2 ) :
	minSum = replaceDig ( x1 , 6 , 5 ) + replaceDig ( x2 , 6 , 5 )
	maxSum = replaceDig ( x1 , 5 , 6 ) + replaceDig ( x2 , 5 , 6 )
	print ( " Minimum ▁ sum ▁ = " , minSum )
	print ( " Maximum ▁ sum ▁ = " , maxSum , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	x1 = 5466
	x2 = 4555
	calculateMinMaxSum ( x1 , x2 )