human
Check whether an array of strings can correspond to a particular number X | Function to find the maximum base possible for the number N.
Function to find the decimal equivalent of the number.
Condition to check if the number is convertible to another base.
Function to check that the array can correspond to a number X.
counter to count the numbers those are convertible to X.
Loop to iterate over the array.
Convert the current string to every base for checking whether it will correspond to X from any base.
Condition to check if every number of the array can be converted to X.
Driver Code.
The set of strings in base from [ 2 , 36 ]"
Solution in Python:
assistant
#Here is code to check whether an array of strings can correspond to a particular number X and the other steps required.
 def val ( c ) :
	if ( c >= '0' and c <= '9' ) :
		return int ( c )
	else :
		return c - ' A ' + 10
def toDeci ( strr , base ) :
	lenn = len ( strr )
	power = 1
	num = 0
	for i in range ( lenn - 1 , - 1 , - 1 ) :
		if ( val ( strr [ i ] ) >= base ) :
			return - 1
		num += val ( strr [ i ] ) * power
		power = power * base
	return num
def checkCorrespond ( strr , x ) :
	counter = 0
	n = len ( strr )
	for i in range ( n ) :
		for j in range ( 2 , 37 ) :
			if ( toDeci ( strr [ i ] , j ) == x ) :
				counter += 1
				break
	if ( counter == n ) :
		print ( " YES " )
	else :
		print ( " NO " )
x = 16
strr = [ "10000" , "20" , "16" ]
checkCorrespond ( strr , x )