Zygodrome Number | Function to check if N is an zygodrome number ; Convert N to string ; Adding a space at the beginning and end of the string ; Traverse the string ; If any character is not same as prev and next then return false ; Driver code
def iszygodromeNum ( N ) : NEW_LINE INDENT s = str ( N ) ; NEW_LINE s = ' ▁ ' + s + ' ▁ ' ; NEW_LINE i = 1 NEW_LINE while i < len ( s ) - 1 : NEW_LINE INDENT if ( ( s [ i ] != s [ i - 1 ] ) and ( s [ i ] != s [ i + 1 ] ) ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return True ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 1122 ; NEW_LINE if iszygodromeNum ( n ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT