Write a program to get all possibilities (in sorted order) for stretching a word to the given size. If the list of required indices is passed, then only those combinations present at those indices should be returned. If the required indices are null, then all the combinations have to be returned.
Input: str = "1234" n = 6 indices = null Output: ["111234", "112234", "112334", "112344", "122234", "122334", "122344", "123334", "123344", "123444"] The above string “1234”, with stretch length can be stretched for different possibilities like "111234", "112334", "112344" etc. The output represents a list of different stretches in a sorted manner. Since the indices are given as null we print the entire list of possibilities Input: str = "1234" n = 6 indices = 1, 5, 9 Output: ["112234", "122334", "123444"] Here only stretched strings of given indices are printed. Input: str = "merit" n = 6 indices = null Output: ["meerit", "meriit", "meritt", "merrit", "mmerit"] Input: str = "java" n = 4 indices = null Output: ["java"] Input : str = "geeksforgeeks" n = 10 indices = null Output:  since the length of the string is greater than the length to be stretched we return an empty index
Code : Python code for get all possibilities for stretching a word to the given size.
['111234', '112234', '112334', '112344', '122234', '122334', '122344', '123334', '123344', '123444']
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- PyQt5 QSpinBox - Getting Stretch factor
- PyQt5 QSpinBox - Setting Stretch factor
- Mahotas - Image Stretch RGB
- Python program to read file word by word
- Python | Word Similarity using spaCy
- Python | Reverse each word in a sentence
- Find frequency of each word in a string in Python
- Generating Word Cloud in Python
- Python | Word Embedding using Word2Vec
- Python | Program that matches a word containing 'g' followed by one or more e's using regex
- Generating Word Cloud in Python | Set 2
- Python | Program to implement Jumbled word game
- Python program for word guessing game
- Python | Removing Initial word from string
- Python | Count occurrences of each word in given text file (Using dictionary)
- Python | TextBlob.Word.spellcheck() method
- Python - Get Nth word in given String
- Python | Replace rear word in String
- Python - Kth word replace in String
- Python program to capitalize the first and last character of each word in a string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet