Sobes.tech
Junior — Senior

Generation of all valid IP addresses from a sequence of digits

livecode

Task condition

Given a string s consisting solely of digits. It is necessary to obtain a list of all possible valid IP addresses that can be formed by placing three dots in the string.

The order of digits must be preserved; permutation is not allowed. Each of the four octets of the IP address must be a number in the range from 0 to 255, written without leading zeros (except for the number zero itself).

Example 1 Input: "25525511135" Output: ["255.255.11.135", "255.255.111.35"]

Example 2 Input: "0000" Output: ["0.0.0.0"]