human
Check if any permutation of array contains sum of every adjacent pair not divisible by 3 | Function to checks if any permutation of the array exists whose sum of adjacent pairs is not divisible by 3.
Count remainder 0.
Count remainder 1.
Count remainder 2.
Condition for valid arrangements.
Given array arr [ ].
Function call"
Solution in Python:
assistant
#Here is code to check if any permutation of array contains sum of every adjacent pair not divisible by 3 and the other steps required.
 def factorsOf3 ( arr , N ) :
	a = 0
	b = 0
	c = 0
	for i in range ( N ) :
		if ( arr [ i ] % 3 == 0 ) :
			a += 1
		elif ( arr [ i ] % 3 == 1 ) :
			b += 1
		elif ( arr [ i ] % 3 == 2 ) :
			c += 1
	if ( a >= 1 and a <= b + c + 1 ) :
		print ( " Yes " )
	elif ( a == 0 and b == 0 and c > 0 ) :
		print ( " Yes " )
	elif ( a == 0 and c == 0 and b > 0 ) :
		print ( " Yes " )
	else :
		print ( " No " )
arr = [ 1 , 2 , 3 , 3 ]
N = len ( arr )
factorsOf3 ( arr , N )