#C13910. Extract Unique IP Addresses
Extract Unique IP Addresses
Extract Unique IP Addresses
You are given a log file content as a multi‐line string. Your task is to extract all unique IPv4 addresses from the log and then output them in ascending order. The order must be determined by comparing each numeric octet. For example, given the IP addresses (a.b.c.d), you should sort them by converting each octet to an integer.
More formally, let an IP address be represented as (a.b.c.d) where (0 \leq a,b,c,d \leq 255). Sort these IP addresses in ascending order such that if (a_1,b_1,c_1,d_1) and (a_2,b_2,c_2,d_2) are two IPs, then (a_1 < a_2), or (a_1 = a_2) and (b_1 < b_2), etc.
You must read the entire log content from standard input (stdin) and output the resulting IP addresses to standard output (stdout), each on a new line.
inputFormat
The input consists of multiple lines representing the log file content. Read from standard input until EOF. The log may contain zero or more IPv4 addresses. Each valid IP address follows the pattern a.b.c.d, where each part is an integer in the range [0, 255].
outputFormat
Output all the unique IPv4 addresses found in the input, sorted in ascending order. Each IP address should appear on a new line. If no valid IP address is found, output nothing.## sample
2023-03-15 12:45:33 INFO 192.168.0.1 - User login successful
192.168.0.1
</p>