[Question]
  [
> 
> [This reminds me when a few years ago someone uploaded a torrent "Hacker tool: complete list of all IP addresses". This was, of course, just a generated list of the ~4 billion IPv4 addresses, but thousands of "h4xx0rz" downloaded it. Look mum, imahacker!](https://meta.stackoverflow.com/questions/307454/stackoverflow-has-been-compromised-post/307456#comment255186_307456)
> 
> 
> 
This was then, but nowadays everybody has switched to [IPv6](https://en.wikipedia.org/wiki/IPv6). (Right?)
Your task is to write a program that **prints out all [IPv6 addresses](https://en.wikipedia.org/wiki/IPv6_address)**.
You should write a full program that takes no input and prints IPv6 addresses, one per line, and no other output. Your program must print all 2128 possible addresses, including invalid ones. Each address must be printed exactly once. You may print the addresses in any order.
Each address may be printed in full, with 8 groups of 4 hexadecimal digits separated by colons, e.g.
```
2001:0db8:85a3:0000:0000:8a2e:0370:7334
```
You may, at your discretion, use any of the standard abbreviations from [RFC 5952](https://www.rfc-editor.org/rfc/rfc5952):
* Leading zeros in a group may be omitted, except that `0` cannot be abbreviated further.
* `::` may be used at most once per address to abbreviate a sequence of one or more all-zero groups.
* The hexadecimal digits may use lowercase or uppercase.
If you achieve the [representation recommendation from RFC 5952](https://www.rfc-editor.org/rfc/rfc5952#section-4) (lowercase letters only, shortest possible representation, with `::` used as early as possible if there are multiple places where it can be used), you get a **-20% bonus**.
Due to the size of the output, your program is not expected to finish while we're sitting there. Your program may be interrupted by external means at some point (`Ctrl`+`C`, pulling out the power, …). Your program must produce output as a stream, so that after a “reasonable” wait, it will have produced some lines. Basically, building a giant string in memory only to print it at the end is not allowed. Any program that would run out of memory on a “standard” PC is disqualified. (Nonetheless, if your program was left to run for sufficiently long, it must print all IPv6 addresses and then exit.)
(If this condition is a problem for web interpreters that run the program until completion and then let you see the output, and you don't have a hosted interpreter, test your program on a smaller version of the problem, and then carefully adjust it to the full 2128.)
Your score is your program's length in bytes, multiplied by 0.8 if you get the bonus. It's code golf, so the lowest score wins.
  
[Answer]
# Python 3, 65 bytes · 0.8 = 52.0
```
from ipaddress import*
n=4**64
while n:n-=1;print(IPv6Address(n))
```
[Answer]
# Pyth, ~~27~~ ~~25~~ 24 bytes
*Note: the code had a bug previously, fixing it saved 1 byte*
```
J^4 64WJj\:c%"%032x"=tJ4
```
Prints the addresses like
```
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe
ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffd
ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc
...
0000:0000:0000:0000:0000:0000:0000:0003
0000:0000:0000:0000:0000:0000:0000:0002
0000:0000:0000:0000:0000:0000:0000:0001
0000:0000:0000:0000:0000:0000:0000:0000
```
Previous (more complicated) version using the pad operator (also 24 bytes):
```
J^4 64WJj\:c.[\032.H=tJ4
```
### Explanation
```
J^4 64                  set J to 2^128
WJ                     while J is not 0:
            =tJ               decrement J
    %"%032x"                 format to length-32 hex string
   c           4            split every 4 chars
j\:                        join by : and print
```
## Pyth, 21 bytes (invalid)
```
jmj\:c.[\032.Hd4^4 64
```
This can't be run since 1) it would consume at least 2132 bytes (252 yobibytes) of memory and 2) the interpreter doesn't like it (2128 doesn't fit in `ssize_t`, so no `list`s of that size). It would print the addresses in lexicographical order. You can try out the algorithm by changing the number(s) in the end to something usable.
[Answer]
# C (with GCC extensions), 76 bytes \* 0.8 = 60.8
```
__uint128_t i;main(){char s[50];for(;inet_ntop(10,&i,s,49),puts(s),++i>0;);}
```
This uses the [128-bit integers GCC extension](https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/_005f_005fint128.html#_005f_005fint128) to simply count up from `::` to `ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff`. `inet_ntop()` correctly formats each address so the -20% bonus can be claimed.
### Output
Using `sed` to output every millionth line up to 10 million:
```
$ ./ipv6all | sed -n '1~1000000p;10000000q'
::
4042:f00::
8084:1e00::
c0c6:2d00::
9:3d00::
404b:4c00::
808d:5b00::
c0cf:6a00::
12:7a00::
4054:8900::
$ 
```
Note I am using a little-endian x86\_64 machine, and that network addresses are typically always in network-order (big-endian), so the endianness is effectively swapped by using `inet_ntop()`. This does not matter - all addresses will still (eventually) be displayed.
[Answer]
# CJam, ~~36~~ 27 bytes
```
G32#{(_"%032x"e%4/':*oNo}h;
```
-9 bytes thanks to @Dennis (I forgot that CJam has string formatting). Prints the addresses lowercase and descending.
For obvious reasons, use the Java interpreter, not the online one. You can replace `G32#` with something smaller for testing online though, e.g. [here's the last 100](http://cjam.aditsu.net/#code=100%20%7B%28_%22%25032x%22e%254%2F'%3A*oNo%7Dh%3B).
### Explanation
```
G32#             16^32 = 2^128. Call this n
{ ... }h;        While loop. The final ; is to pop n at the end
 (               Decrement n
 _               Copy n
 "%032x"e%       String format to hex, padded to 32 digits
 4/              Split into groups of 4
 ':*             Join with colons
 oNo             Output with newline
```
[Answer]
# Python 2.7, 67 bytes
```
n=4**64
while n:n-=1;s='%032x'%n;exec"s=s[4:]+':'+s[:4];"*7;print s
```
As a side effect of the method used to insert the colons, the addresses are printed with the rightmost column appearing at the left:
```
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
fffe:ffff:ffff:ffff:ffff:ffff:ffff:ffff
fffc:ffff:ffff:ffff:ffff:ffff:ffff:ffff
...
0003:0000:0000:0000:0000:0000:0000:0000
0002:0000:0000:0000:0000:0000:0000:0000
0001:0000:0000:0000:0000:0000:0000:0000
```
[Answer]
# Cinnamon Gum, 16 bytes
```
0000000: 678b 36d0 b54c d44d 8bc5 455b 8d0c 0500  g.6..L.M..E[....                               .
```
[Try it online. (TIO limits output)](http://cinnamon-gum.tryitonline.net/#code=MDAwMDAwMDogNjc4YiAzNmQwIGI1NGMgZDQ0ZCA4YmM1IDQ1NWIgOGQwYyAwNTAwICBnLjYuLkwuTS4uRVsuLi4uCg&input=)
## Explanation
The `g` mode puts Cinnamon Gum in *generate mode*. The rest of the string decompresses to this regex:
```
[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]
```
It then creates a generator of all possible strings that match the regex and iterates through it, printing out each one.
Somewhat amusingly, the golfier regex `([0-9a-f]{4,4}:){7,7}[0-9a-f]{4,4}` actually compresses to a longer string than the regex above.
[Answer]
# Verilog, 335
My first Verilog submission, probably could use more golfing but I don't have the energy to do so right now. `c` is clock, `o` is ASCII output. Does not qualify for formatting bonus due to zero-padding instead of abbreviating.
```
module b(output[0:38]o,input c);reg[127:0]a;wire[0:39]d;assign o=d[0:38];always @(posedge c) a<=a+(~(&a));genvar i,j;generate for(i=0;i<8;i=i+1) begin:q for(j=0;j<4;j=j+1) begin:r assign d[5*i+j]=a[16*i+4*j:16*i+4*j+7]>9?{4'h6,a[16*i+4*j:16*i+4*j+7]-9}:{4'h3,a[16*i+4*j:16*i+4*j+7]};end assign d[5*i+4]=8'h3A; end endgenerate endmodule
```
This is a simple iteration followed by some bit-twiddling to make the output ASCII. I chop the colon after the last group with a small hack. Synthesizes and appears to work for xc3s500e-4ft256-4 on ISE 13.7 lin64.
[Answer]
# Pyth, 21 bytes
```
KJ^8CdWJj\:ct.H+K=tJ4
```
Uses a while loop with `J` as the iterator variable. Initializes the maximum using `8^chr(' ')`. Pads by adding that initial value, converting to hex, then removing the first character.
[Answer]
# C, 91-126 bytes
My original version, 119 bytes.
```
long a[9],i;
f(long*x){if(65536&++*x)*x=0,f(x+1);}
main(){for(;!a[8];f(a))for(i=7;i+1;i--)printf(i?"%lx:":"%lx\n",a[i]);}
```
Best golfed portable-ish version, 103 bytes (thanks @Dennis for some of these concepts)
```
long*p,a[9];
main(i){while(!a[8]){
for(i=8;i--;printf(i?"%lx:":"%lx\n",a[i]));
for(p=a;++*p>>16;*p++=0);}}
```
Explanation: The algorithm itself is reasonably straightforward. I used long rather than unsigned int because it's shorter. Declaring them at the file level means everything's preinitialized with zeros. The `f` function is a simple increment with carry that operates on the low 16 bits of each word. The loop ends when it carries into the 129th bit.
Iterating backwards for the printf means that we print the addresses in the "proper" order and also the check for printing a newline is a few characters shorter.
This does use some non-portable constructs. It's best regarded as a K&R dialect of C, since it uses implicit int return types and does not include stdio.h. And my use of long was informed by this - on most modern systems int is sufficient because it's 32 bits. This could probably run unmodified on PDP-11 Unix.
However, it can be shorter. If we assume that we can use int (either as a type wider than 16 bits, or a type of exactly 16 bits with various properties that happen to be true on many systems such as twos complement and arithmetic rollover), we can get rid of the stuff related to using long.
Version for int wider than 16 bits, 97 bytes.
```
a[9],*p;main(i){while(!a[8]){
for(i=8;i--;printf(i?"%x:":"%x\n",a[i]));
for(p=a;++*p>>16;*p++=0);}}
```
Version for 16-bit systems, 91 bytes.
```
a[9],*p;main(i){while(!a[8]){
for(i=8;i--;printf(i?"%x:":"%x\n",a[i]));
for(p=a;!++*p;p++);}}
```
Oddly enough, though, the original K&R compiler didn't actually support the declaration without int (it compiles fine, but treats the variables as external and therefore undefined at link time), so an additional three bytes are needed to change the declaration to `int*p,a[9];` for a total of 94.
Also, if the assumption that it is interrupted before completing output were a hard constraint, we could remove the end check, saving five bytes.
Bonus: fully ANSI portable version, 126 bytes:
```
#include<stdio.h>
long*p,i,a[9];
int main(){while(!a[8]){
for(i=8;i--;printf(i?"%lx:":"%lx\n",a[i]));
for(p=a;++*p>>16;*p++=0);}}
```
Newlines in all versions are inserted for readability and in locations where whitespace is not required, and are excluded from the byte count, except for the newline after the `#include` line in the ANSI version.
All versions except the ANSI version fall through at the end of main and therefore may return a spurious exit code to the operating system.
[Answer]
# AutoIt3, ~~142~~ 231 Bytes
```
For $a=0 To 2^32-1
For $b=0 To 2^32-1
For $c=0 To 2^32-1
For $d=0 To 2^32-1
$s=StringFormat("%08x%08x%08x%08x",$a,$b,$c,$d)
For $j=0 To 8
ConsoleWrite(StringMid($s,$j*4+1,4)&($j<7?":":""))
Next
ConsoleWrite(@LF)
Next
Next
Next
Next
```
## Explanation
* `For $a=0 To 2^32-1`: Iterate 4 times over 0-2^32 ((2^32)^4=2^128) possible combinations.
* `$s=StringFormat("%08x%08x%08x%08x",$a,$b,$c,$d)`: Convert the numbers to a hexadecimal string with a length of 32 (4\*32).
* `For $j=0 To 8`: Iterate over all 8 sections of the string.
* `ConsoleWrite(StringMid($s,$j*4+1,4)&($j<7?":":""))`: Extract the next 4 characters from the string and add a colon (`:`) at the end, if we haven't reached the last section, then output everything to the console
* `Next`: End the inner for-loop
* `ConsoleWrite(@LF)`: Add a line-feed at the end of the line
* `Next`: End the outer for-loops
Expected output size: (One line (39 bytes) + line-feed) (=40 bytes) \* 2^128 = 1.361\* 10^16 YB (yottabytes)
[Answer]
# Commodore BASIC 2.0, 339 bytes
In order to get lower-case hex digits, this program is written in "shifted mode" (press `<SHIFT>+<C=>`)
```
1k=65535:a=0
2fOb=0tok:fOc=0tok:fOd=0tok:fOe=0tok:fOf=0tok:fOg=0tok:fOh=0tok
3x=a:goS6:?":";:x=b:goS6:?":";:x=c:goS6:?":";:x=d:goS6:?":";:x=e:goS6:?":";:x=f
4goS6:?":";:x=g:goS6:?":";:x=h:goS6:?
5nE:nE:nE:nE:nE:nE:nE:nE:a=a+1:ifa<65536tH2
6y=x/4096:goS7:y=x/256aN15:goS7:y=x/16aN15:goS7:y=xaN15:goS7:reT
7?mI("0123456789abcdef",y+1,1);:reT
```
Simply making this *work* on the Commodore 64 was a challenge, because of memory, screen size, data size, and other limitations. I considered implementing the abbreviated representation, but other limitations (such as the undocumented inability to use array elements as loop indices) meant it would increase the length of the program by an estimated 1000 bytes.
Line 7 is an implementation of `HEX$()`, which Commodore BASIC 2.0 is lacking. I can't use a `DEF FN` for this because those can only return numbers, not strings. Line 6 is a subroutine that applies it to a group of four digits, which would have been considerably shorter if functions could return strings.
Lines 2 and 5 are eight nested loops, implemented as seven "for" loops and a conditional goto because eight "for" loops, when combined with the two "gosubs" for printing out the address, will overflow the C64's tiny stack.
A C64 can print out about 1.2 addresses per second, for an estimated runtime of 1.3\*10^31 years.
[Answer]
### PowerShell (v4), 193 166 162 145 103 bytes
TimmyD's no-bonus version at 103 bytes:
```
$i=[bigint]::Pow(4,64);while($i-gt0){('{0:X32}'-f($i-=1)-replace'0(?=.{32})'-re‌​place'.{4}(?!$)','$0:')}
```
---
Previous with-bonus version at 145 \* 0.8 = 116 bytes
With help from [TimmyD](https://codegolf.stackexchange.com/users/42963/timmyd) and [tomkandy](https://codegolf.stackexchange.com/users/25181/tomkandy), who points out that `0 -eq $false` but `([bigint]0) -eq $true`. So all my previous versions won't terminate.
```
$i=[bigint]::Pow(4,64);while($i-gt0){$i-=1;[IPAddress]::Parse((('{0:X32}'-f$i
)-replace'0(?=.{32})'-replace'.{4}(?!$)','$0:')).IPAddressToString}
```
---
Previously at 162, before some regex changes:
```
$i=[bigint]::Pow(4,64)
while($i){$i-=1;if(($x='{0:X32}'-f$i).Length-eq33){$x=$x.Substring(1)}
[IPAddress]::Parse(($x-replace'.{4}(?!$)','$0:')).IPAddressToString}
```
*"A challenge where PowerShell ought to be reasonably competetive!"* - me, before I tried it.
**Explanation**
```
# PowerShell (PS) has no IP address arithmetic, e.g. IP + 1
#- PS has no 128 bit integers
#- PS has no automatic bignums
# Start from the top, with the BigInteger specialised Power()
$i = [BigInt]::pow(4,64)
# Loop 4**64 through 1, work with $i-1 for ff... -> ::0
while ($i) {
    # PS has no decrement operator for bignums
    # (no using $i-- in the while loop test)
    $i-=1
    # The Net.IPAddress class can't turn a BigInteger
    # into an IPv6 address directly. And because it mashes
    # IPv4 and IPv6 into one class, there's no obvious way 
    # to make a small number always cast to an IPv6 address.
    # Format the bignum as a string of 32 hex digits.
    $x = '{0:X32}' -f $i
    # The BigInteger often formats as /33/ hex digits, 
    # with a leading zero (to avoid unintentional +/- sign bits)
    # ( https://msdn.microsoft.com/library/dd268287 )
    # So remove the leading 0, if there is one
    if (($x).Length-eq33){$x=$x.Substring(1)}
    # I can't always remove the leading zero, because it 
    # can't parse FFFFF... into an address without colons
    # and this regex replace into groups of 4 with colons
    # would go wrong at length 31. No : after the last group
    # This is still better than split/join ... because there
    # isn't a split-into-groups-of-N that I know of.
    $x = ($x -replace '.{4}(?!$)', '$1:'
   
    # Woo! * 0.8 bonus! 45 characters to save 38! :D
    [IPAddress]::Parse($x).IPAddressToString
}
```
[Answer]
# AutoIt3, 137 Bytes
```
For $i=0 To 4^64
$s=StringFormat("%032x",$i)
For $j=0 To 7
ConsoleWrite(StringMid($s,$j*4+1,4)&($j<7?':':''))
Next
ConsoleWrite(@LF)
Next
```
[Answer]
# [Regenerate](https://github.com/dloscutoff/Esolangs/tree/master/Regenerate) `-a`, 24 bytes
```
(($3:!)[0-9a-f]{4}()){8}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72qKDU9NS-1KLEkdVm0km6iUuyCpaUlaboWOzQ0VIytFDWjDXQtE3XTYqtNajU0NastaiHSUFULoDQA)
```
(
    # Match ":" iff we're not on the first iteration
    (
        $3        # Match iff we're not on the first iteration
        :         # Match ":"
    !             # Short-circuiting alternation - only try matching the below
                  # if it was impossible for the above to match.
                  # Do nothing
    )
    [0-9a-f]{4}   # Match 4 hexadecimal digits
    ()            # $3 = signal that we're not on the first iteration anymore
)
{8}               # Repeat the above 8 times
```
Alternative 24 bytes:
```
(({#1}:!)[0-9a-f]{4}){8}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72qKDU9NS-1KLEkdVm0km6iUuyCpaUlaboWOzQ0qpUNa60UNaMNdC0TddNiq01qNastaiHSUFULoDQA)
It might not be intended that this is possible, but Regenerate allows a quantifier to be preceded by nothing. This is what's happening with `{#1}` - it's impossible for it to match on the first iteration because `$1` hasn't been captured yet and doesn't have a length. On subsequent iterations, a match of nothing gets repeated 4 times (the length of `$1`).
[Answer]
# Python 2, 95 bytes
```
def i(p=0):
 while p<4**64:print':'.join(hex(p)[2:].zfill(32)[4*s:4*s+4]for s in range(8));p+=1
```
Simply goes through every number from 0 to 2^128. First it converts the current number to hexadecimal string, then strips off the `'0x'` that that function gives. Next it adjusts the string to have 32 zeros in the front and then breaks it up into groups of four. Finally it joins the groups of four with colons, prints that out and adds 1 to the current number. Has the added bonus that you can start it at any value if you give it one, but no input is needed.
[Answer]
# Haskell 111
```
s[]=[[]]
s(a:b)=[y:z|z<-s b,y<-a]
r=replicate
main=mapM putStrLn$s$tail$concat$r 8$":":r 4"0123456789abcdef"
```
With my own sequence function `s` it no longer leaks memory, but does not feel golfed any more.
[Answer]
# CBM BASIC v7.0 (166 characters)
```
a=65535
fOi=0toa:fOj=0toa:fOk=0toa:fOl=0toa:fOm=0toa:fOn=0toa:fOo=0toa:fOp=0toa:?hE(i)":"hE(j)":"hE(k)":"hE(l)":"hE(m)":"hE(n)":"hE(o)":"hE(p):nE:nE:nE:nE:nE:nE:nE:nE
```
[Mark's answer](https://codegolf.stackexchange.com/a/60318/46220) is for the Commodore 64's BASIC 2.0, which lacks a built-in command for printing numbers in hexadecimal. However, thanks to the `HEX$()` function in BASIC 7.0, the Commodore 128 version is much shorter. It doesn't fit on a single logical line (which on the C128 is limited to 160 characters) but can still be entered as two separate lines in direct mode.
[Answer]
# Ruby 75
```
x=->s,n{n>0?65536.times{|m|x.(s+?:*(8<=>n)+m.to_s(16),n-1)}: p(s)};x.('',8)
```
This is a recursive solution that takes a each prefix and finds every possible suffix. Recursively.
[Answer]
# [Zsh](https://www.zsh.org/) `-P`, 60 bytes
```
x=({0..9} {a..f})
eval for\ {1..8}' ($x$x$x$x)<<<${(j/:/)@}'
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjWbSSboBS7IKlpSVpuhY3bSpsNaoN9PQsaxWqE_X00mo1uVLLEnMU0vKLYhSqDfX0LGrVFTRUKiBQ08bGRqVaI0vfSl_ToVYdYgbUqAVQGgA) (Warning: if you don't click the kill button fairly quickly, your browser will run out of memory and crash)
`eval for\ {1..8}` creates 8 nested loops using the loop variables `$1`, `$2`, ..., `$8`. These numbered variables can then be referred to implicitly using `$@` (here, they're joined with colons using `${(j/:/)}`).
The `<<<${...}` section is actually repeated for each level of nested loop as well, but (apart from the last one) they all do nothing, because they feed into the next loop, which ignores its input.
The `-P` option enables an implicit cartesian product on the adjacent expansions `$x$x$x$x`. This is the shortest way I could find to count up to `0xffff` *in hex* without needing to convert each loop variable to hex individually.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 21 bytes
```
₇E(nk6τ₅32ε\0*p4ẇ\:j,
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%E2%82%87E%28nk6%CF%84%E2%82%8532%CE%B5%5C0*p4%E1%BA%87%5C%3Aj%2C&inputs=&header=&footer=)
Ugh, we really need a zfill builtin.
[Answer]
# [Go](https://go.dev), \$243 \times 0.8 = \$ 194.4 bytes
```
import(."fmt";."net/netip")
func F(){for a,M:=0,1<<32-1;a<M;a++{for b:=0;b<M;b++{for c:=0;c<M;c++{for d:=0;d<M;d++{s:=""
for n,k:=0,Sprintf("%08x%08x%08x%08x",a,b,c,d);n<8;n++{s+=k[4*n:4*(n+1)]+":"}
A,_:=ParseAddr(s[:len(s)-1])
Println(A)}}}}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=TdAxasMwFAbgXacwgoAUyWncZjCSPXjpFgh0DKHIkhWM42djKxAoOUkXU-jWqbfpOXqBSomHCh6C70cPfr1_HLvpq1e6UccqalUNn2dn4_Tnt277bnBkhW3rsFxhqNyDn7rHFNkz6OiZ0DfbDZHiW5GveZJlT49xIlW2lYqxW1T6QJYeyhl0AO1Bz2ACGA_GwyhyjFFg4E3Y-dIPNThL8GKdXv4P5oqXXHNDJWSphPCY5c1-swSxWRJgCT0wLPAVFfxV5Ds1jFVhzEDGvThVQEYaJweKdmH9CUhBr-Hcq3_f2oWv8AWRb4nmYJru9x8)
Prints to STDOUT. Uses the `netip.Addr` type from the Golang standard library to do the formatting for me.
### Explanation
```
import(."fmt";."net/netip")
func F(){
for a,M:=0,1<<32-1;a<M;a++{ // first 8 digits
for b:=0;b<M;b++{           // next  8 digits
for c:=0;c<M;c++{           // next  8 digits
for d:=0;d<M;d++{           // final 8 digits
k:=Sprintf("%08x%08x%08x%08x",a,b,c,d)  // join the numbers into a single string
s:=""
for n:=0;n<8;n++{s+=k[4*n:4*(n+1)]+":"} // split into 8 groups of 4, split by colons
A,_:=ParseAddr(s[:len(s)-1])            // parse the address
Println(A)}}}}}                         // print using the default String() method, which formats the address
```
[Answer]
## Tcl ~~341~~ ~~318~~ 301
```
proc ip6 {p c} {
    set s %x:%x:%x:%x:%x:%x:%x:%x
    set p [scan $p $s]
    while {[set d 7]} {
        $c [format [string map {x 04x} $s] {*}$p]
        while {[set i [lindex $p $d]]==0xFFFF} {
            lset p $d 0
            if {!$d} return
            incr d -1
        }
        lset p $d [incr i]
    }
}
ip6 fFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:0000 puts
```
]