We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c3e9e67 + 4d50977 commit 3bd110eCopy full SHA for 3bd110e
jumping_number.py
@@ -0,0 +1,15 @@
1
+#Given a positive number N, check if the number is a Jumping number or not.
2
+#A number is defined as a Jumping Number if all adjacent digits in it have an absolute difference of 1.
3
+#For example 2, 23 and 4343456 are Jumping numbers but 296 and 89498 are not
4
+
5
+num = input("Enter a number ")
6
+lst = [int(x) for x in num]
7
+n = len(lst)
8
+res = 1
9
+for ele in range(0,n-1):
10
+ if abs(lst[ele] - lst[ele+1]) != 1:
11
+ res = 0
12
+if res == 1:
13
+ print("JUMPING NUMBER")
14
+else:
15
+ print("NOT A JUMPING NUMBER")
0 commit comments