human
Give me a code to check if a number is formed by Concatenation of 1 , 14 or 144 only and the other steps required given the following:
Check if a number is formed by Concatenation of 1 , 14 or 144 only | Function to check if a number is formed by Concatenation of 1 , 14 or 144 only.
check for each possible digit if given number consist other then 1 , 14 , 144 print NO else print YES.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if a number is formed by Concatenation of 1 , 14 or 144 only and the other steps required.
 def checkNumber ( N ) :
	temp = N
	while ( temp > 0 ) :
		if ( temp % 1000 == 144 ) :
			temp /= 1000
		elif ( temp % 100 == 14 ) :
			temp /= 100
		elif ( temp % 10 == 1 ) :
			temp /= 10
		else :
			return " YES "
	return " NO "
N = 1414 ;
print ( checkNumber ( N ) ) ;