human
Modify array by removing characters from their Hexadecimal representations which are present in a given string | Function to convert a decimal number to its equivalent hexadecimal number.
Function to convert hexadecimal number to its equavalent decimal number.
Stores characters with their respective hexadecimal values.
Stores answer.
Traverse the string.
If digit.
If character.
Return the answer.
Function to move all the alphabets to front.
Function to modify each array element by removing characters from their hexadecimal representation which are present in a given string.
Traverse the array.
Stores hexadecimal value.
Remove the characters from hexadecimal representation present in string S.
Stores decimal value.
Replace array element.
Print the modified array.
Given array.
Given string.
Function call to modify array by given operations"
Solution in Python:
 ... Give me a code to modify array by removing characters from their Hexadecimal representations which are present in a given string and the other steps required?
assistant
#Here is code to modify array by removing characters from their Hexadecimal representations which are present in a given string and the other steps required.
 def decHex ( n ) :
	alpha = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ]
	ans = ' '
	while n :
		if n % 16 < 10 :
			ans += str ( n % 16 )
		else :
			ans += alpha [ n % 16 - 10 ]
		n //= 16
	ans = ans [ : : - 1 ]
	return ans
def hexDec ( convertedHex ) :
	mp = { " A " : 10 , " B " : 11 , " C " : 12 , " D " : 13 , " E " : 14 , " F " : 15 }
	ans = 0
	pos = 0
	for i in convertedHex [ : : - 1 ] :
		if i . isdigit ( ) :
			ans += ( 16 ** pos ) * int ( i )
		else :
			ans += ( 16 ** pos ) * mp [ i ]
		pos += 1
	return ans
def removeChars ( hexaVal , S ) :
	setk = set ( )
	for i in S :
		setk . add ( i )
	ans = ' '
	for i in hexaVal :
		if i in setk :
			continue
		ans += i
	return ans
def convertArr ( arr , S ) :
	for i in range ( len ( arr ) ) :
		hexaVal = decHex ( arr [ i ] )
		convertedHex = removeChars ( hexaVal , S )
		decVal = hexDec ( convertedHex )
		arr [ i ] = decVal
	print ( arr )
arr = [ 74 , 91 , 31 , 122 ]
S = "1AB "
convertArr ( arr , S )