45
5
This was then, but nowadays everybody has switched to IPv6. (Right?)
Your task is to write a program that prints out all IPv6 addresses.
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:
- 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 (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.
22This is 5.445*10¹⁵ yottabytes. To store all of that data, you need at least 15 Earth-sized datacenters containing nothing but hard drives packed in as tightly as possible. That's one big torrent..... – Kaz Wolfe – 2015-10-07T09:26:17.680
7@Mew I'm wondering how small the file would be compressed (using some generic compression like gzip) though. – SztupY – 2015-10-07T12:54:09.647
35@SztupY: apparently the output can be compressed to 25 bytes (Decompression algorithm = a Pyth interpreter, compression algorithm = posting to PPCG) From lurking on this site, it seems that Pyth is a rather generic compressed format. – Ben Voigt – 2015-10-07T16:24:43.677
3In my experience, @Gilles is a real SO heavyweight! Glad to see you bringing questions to our little PPCG corner of SO! Also fun for me to see networking-related questions. – Digital Trauma – 2015-10-07T18:08:54.943
5This reminds me of that "iterate over all possible GUIDs" question on SO. – MikeTheLiar – 2015-10-07T19:08:24.367
Should consider additional bonuses if someone wants to use the representation described in rfc 1924... or as another challenge.
– None – 2015-10-07T19:14:54.6601Can a Verilog solution on FPGA hardware be accepted? Could the output format then be parallel ASCII? – Reinstate Monica - ζ-- – 2015-10-07T21:53:45.927
@hexafraction Um, I don't know. I guess so? I can't find an applicable meta policy. – Gilles 'SO- stop being evil' – 2015-10-07T22:12:45.047
@BenVoigt Now you just need to write a compression algorithm. :) – mbomb007 – 2015-10-08T13:32:54.880
1You know, this idea of a generated file suggests another challenge: Make a function that generates a requested byte range from a file containing all ipv6 addresses. – Random832 – 2015-10-08T13:45:33.530
1
@BenVoigt there's a long running AI/compression challenge based on handing in (their dataset compressed + your decompresser), on the idea that identifying patterns is linked to intelligence, more intelligence == better compression, and you can't cheat by handing in 1 byte + hide the data in the decompresser. CodeGolf is just like that, except with human compressers and we can offload everything possible into the interpreter. It would be a bit of a different site if we scored (code size + interpreter/compiler size).
– TessellatingHeckler – 2015-10-08T18:01:35.260@TessellatingHeckler: Meta question related to that: http://meta.codegolf.stackexchange.com/q/7104/11335
– Ben Voigt – 2015-10-08T19:31:31.9571What is this "IPv6" you speak of? – John Odom – 2015-10-08T20:52:07.477