#C (with GCC extensions), 76 bytes * 0.8 = 60.8
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 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
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.