views:

66

answers:

1

Just out of curiosity, does there exist a valid zip-file (according to format spec) that, contains nothing but itself?

Put another way, does the function implemented by unzip have a fix-point?

Can I write a program to search for such a fix-point in a intelligent (not-exhaustive) way?

I've thought about the opposite as well, i.e. if zip has a fix-point, but presumably a file can be compressed in different ways (different algorithms, different levels of compression and so on), thus whether or not f = zip(f) holds for some file f is probably implementation dependent. Since the zip-compression is loss-less however, the case for unzip should probably have a "formal" answer.

Has anyone explored this? Any pointers to related URLs are appreciated.

+6  A: 

You can read about it here: http://research.swtch.com/2010/03/zip-files-all-way-down.html

Here you will find r.zip, which contains itself.

Magnus Hoff
Hah! Great article. Thanks.
aioobe
My pleasure :-)
Magnus Hoff
Sent the file to a few friends.... "Here guys, a fun pic... it's a bitmap, so I zipped it a few times to get the size down." ;)
aioobe