human
Check if given permutation of 1 to N can be counted in clockwise or anticlockwise direction | Python3 program to check clockwise or counterclockwise order in an array.
Comparing the first and last value of array.
If the count is greater than 1 then it can 't be  represented in required order.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to check if given permutation of 1 to N can be counted in clockwise or anticlockwise direction and the other steps required.
 def check_order ( arr ) :
	cnt = 0
	for i in range ( len ( arr ) - 1 ) :
		if ( abs ( arr [ i + 1 ] - arr [ i ] ) > 1 ) :
			cnt += 1
	if ( abs ( arr [ 0 ] - arr [ len ( arr ) - 1 ] ) > 1 ) :
		cnt += 1
	if ( cnt > 1 ) :
		return False
	return True
arr = [ 2 , 3 , 4 , 5 , 1 ]
if ( check_order ( arr ) ) :
	print ( " YES " )
else :
	print ( " NO " )