- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Program to find all contiguously increasing numbers in start end range in Python

Suppose we have two numbers start and end, we have to find a sorted list of integers such that every number e in range [start, end] both inclusive and the digits of e are contiguously increasing. An example of continuously increasing number is 5678, but 169 is not.

So, if the input is like start = 10 end = 150, then the output will be [12, 23, 34, 45, 56, 67, 78, 89, 123]

To solve this, we will follow these steps −

- s := all 9 digits as a string "123456789"
- a := a new list
- for i in range 0 to 8, do
- for j in range i + 1 to 9, do
- x := (substring of s from index i to j-1) as number
- if start <= x <= end, then
- insert x into a

- for j in range i + 1 to 9, do
- sort the list a and return

## Example

Let us see the following implementation to get better understanding −

def solve(start, end): s = "123456789" a = [] for i in range(9): for j in range(i + 1, 10): x = int(s[i:j]) if start <= x <= end: a += (x,) return sorted(a) start = 10 end = 150 print(solve(start, end))

## Input

10, 150

## Output

[12, 23, 34, 45, 56, 67, 78, 89, 123]

- Related Questions & Answers
- Program to find length of longest contiguously strictly increasing sublist after removal in Python
- Display all the numbers from a range of start and end value in JavaScript?
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Python Program to Find All Numbers which are Odd and Palindromes Between a Range of Numbers
- Program to find bitwise AND of range of numbers in given range in Python
- MySQL query to count days in date range with start and end date
- Program to sort all even and odd numbers in increasing and decreasing order respectively in Python
- Python Program to Print all Numbers in a Range Divisible by a Given Number
- Program to find all missing numbers from 1 to N in Python
- Find groups of strictly increasing numbers in a list in Python
- Program to find length of longest increasing subsequence in Python
- Program to find all upside down numbers of length n in Python
- Print all n-digit strictly increasing numbers in C++
- Program to find out the number of special numbers in a given range in Python

Advertisements