human
Check if any permutation of a number is divisible by 3 and is Palindromic | Function to check if any permutation of a number is divisible by 3 and is Palindromic.
Hash array to store frequency of digits of n.
traverse the digits of integer and store their frequency.
Calculate the sum of digits simultaneously.
Check if number is not divisible by 3.
If more than one digits have odd frequency , palindromic permutation not possible.
Driver Code"
Solution in Python:
assistant
#Here is code to check if any permutation of a number is divisible by 3 and is Palindromic and the other steps required.
 def isDivisiblePalindrome ( n ) :
	hash = [ 0 ] * 10
	digitSum = 0
	while ( n ) :
		digitSum += n % 10
		hash [ n % 10 ] += 1
		n //= 10
	if ( digitSum % 3 != 0 ) :
		return False
	oddCount = 0
	for i in range ( 10 ) :
		if ( hash [ i ] % 2 != 0 ) :
			oddCount += 1
	if ( oddCount > 1 ) :
		return False
	else :
		return True
n = 34734
if ( isDivisiblePalindrome ( n ) ) :
	print ( " True " )
else :
	print ( " False " )