#B4148. IPv6 Address Conversion

    ID: 11805 Type: Default 1000ms 256MiB

IPv6 Address Conversion

IPv6 Address Conversion

IPv6 addresses are written using 128-bit numbers. To simplify writing, these are often split into 8 groups, each representing 16 bits, written in hexadecimal form. Two abbreviations are allowed: (1) leading zero omission in each group; (2) one occurrence of consecutive groups of zeros may be replaced by a double colon (::). Given a possibly abbreviated IPv6 address in hexadecimal format, convert it to its full binary representation. Each of the 8 groups should be represented by exactly 16 binary digits (with leading zeros if necessary) and groups should be separated by a colon.

For example, the IPv6 address 2001:DB8:130F::9C0:876A:130B represents the full address with groups: 2001, DB8, 130F, 0000, 0000, 09C0, 876A, 130B which in binary would be: 0010000000000001:0000110110111000:0001001100001111:0000000000000000:0000000000000000:0000100111000000:1000011101101010:0001001100001011.

inputFormat

A single line containing an IPv6 address in hexadecimal format, possibly using abbreviated notation (leading zero omission and/or :: for consecutive groups of zeros).

outputFormat

Output the full binary representation of the IPv6 address. The output should consist of 8 groups separated by a colon (:), where each group is a 16-digit binary number.

sample

2001:0DB8:130F:0000:0000:09C0:876A:130B
0010000000000001:0000110110111000:0001001100001111:0000000000000000:0000000000000000:0000100111000000:1000011101101010:0001001100001011