File tree
Expand file treeCollapse file tree1 file changed
+15
-0
lines changed Expand file treeCollapse file tree1 file changed
+15
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
|
| 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") |
You can’t perform that action at this time.
0 commit comments