All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Shrink needed (Posted on 2006-10-18) Difficulty: 2 of 5
A file compressor is great for shrinking stored files, but it depresses me whenever I see a file grow instead of shrink. So what I am looking for is a file compression algorithm that never inflates any files, although it is allowed that some files (not all of course!) have the same length after "compression". Ideally it should work on files of all sizes, but I would be satisfied with a compressor that operates only on files larger than 1MB. Can you provide such an algorithm? No programming knowledge is required for this problem.

See The Solution Submitted by JLo    
Rating: 3.6667 (6 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Provably impossible Comment 26 of 26 |

The puzzle, as described above, is impossible.

Either the "compressed" file needs to have a header (and thus may be larger than the origonal), or compressing and then uncompressing the file may not result in the origonal file.

Proof: Take a large file. Compress it with the magic algorithm, repeatedly, untill it compresses no more. Call this file A.

Compress this file once more. At this stage, you have 2 options:

Option 1: Add additional information to say "The following file is not compressed" and include the rest of the file as-is. This breaks the criteria, as it must, by definition, be larger than the uncompressed file (File A), since it contains the marker, plus the uncompressible file.

Option 2: Leave the uncompressible file exactly as-is - that is, identical to file A. Now run this through the uncompressor - you will get a different file. In other words, uncompress(compress(x)) may not be x.

QED.


  Posted by Jort Bloem on 2006-10-23 22:24:16
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (12)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information