Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions JumpingNumber/Jumping_Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Given a positive number N, check if the number is a Jumping number or not. A number is defined as a Jumping Number if all adjacent digits in it have an absolute
#difference of 1. For example 2, 23 and 4343456 are Jumping numbers but 296 and 89498 are not

num = input("Enter a number ")
lst = [int(x) for x in num]
n = len(lst)
res = 1
for ele in range(0,n-1):
if abs(lst[ele] - lst[ele+1]) != 1:
res = 0
if res == 1:
print("JUMPING NUMBER")
else:
print("NOT A JUMPING NUMBER")
13 changes: 13 additions & 0 deletions JumpingNumber/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Program to identify jumping numbers

Jumping numbers are the numbers whose adjacent digits differ by one. <br>
For example, 45654 is a jumping number.

## Working of the program

This script is a basic program for deciding whether a given number is a jumping number or not.<br>
The user is prompted to enter a number and the code works on identifying its type.

#### Here's a screenshot of the working script :

![image](https://user-images.githubusercontent.com/71630760/117422991-d537c580-af3d-11eb-9de0-2683b5d920f2.png)