We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
n = int(input())
d = n
x = []
a = n
def check(a,d):
if(d==0):
pass
elif(d==10):
x.append(1)
elif(a<10):
x.append(a)
d = ((d-a)/10)
check(d,d)
elif(a%10==0 and a==10):
x.append(0)
d = (d/10)
check(d,d)
elif(a%10==0):
a=a/10;
check(a,d)
else:
a=a%10;
check(a,d)
check(a,d)
x.reverse()
l = len(str(n))
count = 0
for i in range(0,l-2):
if((x[i]-x[i+1])==-1 or (x[i]-x[i+1])==1):
count = count + 1
print(count)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #178: Step Numbers
You are viewing a single comment's thread. Return to all comments →
What wrong in this Code?