human
Write me a code to program to add two integers of given base and the other steps required given the following:
Program to add two integers of given base | Function to find the sum of two integers of base B.
Padding 0 in front of the number to make both numbers equal.
Condition to check if the strings have lengths mis - match.
Loop to find the find the sum of two integers of base B.
Current Place value for the resultant sum.
Update carry.
Find current digit.
Update sum result.
Driver Code.
Function Call"
Solution in Python:
assistant
#Here is code to program to add two integers of given base and the other steps required.
 def sumBaseB ( a , b , base ) :
	len_a = len ( a )
	len_b = len ( b )
	s = " " ;
	sum = " " ;
	diff = abs ( len_a - len_b ) ;
	for i in range ( 1 , diff + 1 ) :
		s += "0"
	if ( len_a < len_b ) :
		a = s + a
	else :
		b = s + b ;
	carry = 0 ;
	for i in range ( max ( len_a , len_b ) - 1 , - 1 , - 1 ) :
		curr = carry + ( ord ( a [ i ] ) - ord ( '0' ) ) + ( ord ( b [ i ] ) - ord ( '0' ) ) ;
		carry = curr // base
		curr = curr % base ;
		sum = chr ( curr + ord ( '0' ) ) + sum
	if ( carry > 0 ) :
		sum = chr ( carry + ord ( '0' ) ) + sum ;
	return sum
a = "123"
b = "234"
base = 6
sum = sumBaseB ( a , b , base ) ;
print ( sum )