Playful puzzle

R

Roedy Green

I offer this is the spirit of play. It is not a serious problem.

Lets say you had a PAD file that among other things included the
zipped size of the distributable inside it in ASCII bytes. But the
PAD file itself is inside the distributable.

In the worst case, how many times must you adjust the size in the PAD
and rezip with java.util.zip if you want to be 100% sure it is bang on
accurate?
--
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.
 
A

Andreas Leitgeb

Roedy Green said:
I offer this is the spirit of play. It is not a serious problem. :)

Lets say you had a PAD file that among other things included the
zipped size of the distributable inside it in ASCII bytes. But the
PAD file itself is inside the distributable.
In the worst case, how many times must you adjust the size in the PAD
and rezip with java.util.zip if you want to be 100% sure it is bang on
accurate?

In the worst case, you might never ever get a bang:

e.g. you start with number 00000, and may get a zipped file of 55554 bytes,
then you write 55554 (with a tiny bit more entropy) and now get 55555 bytes.
Then you write 55555 (which that tiny bit less entropy) and get 55554 bytes...

PS: I have no idea, if such cycles will really show up, but it appears
plausible to me that they could...

PPS: there may, however be a way out: By giving a slightly larger size
and a means to add further entropy into the pad-file or into an extra
file of the distributable, you can add just as much rubbish, until the
initial size-overestimate is reached - and if it is surpassed rather than
reached, then re-iterate with incremented size-estimate.
 
D

Daniel Pitts

I offer this is the spirit of play. It is not a serious problem.

Lets say you had a PAD file that among other things included the
zipped size of the distributable inside it in ASCII bytes. But the
PAD file itself is inside the distributable.
What is an ASCII byte? Do you mean the number of ASCII characters?
In the worst case, how many times must you adjust the size in the PAD
and rezip with java.util.zip if you want to be 100% sure it is bang on
accurate?

It may be the case that there is no answer, unless you add padding. It
is possible that if you underestimate by one, then adding one will
actually change the file size to be smaller!

Alternatively, there is a way to store data into a ZIP file that doesn't
actually compress the data, so you can in that way deterministically
figure out the final size :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Ubunto 74
Where am I? 10
constructing a constant HashMap 19
New Java releases 1.6.0_29 and 1.7.0_01 3
@see scope 6
Java control panel anomaly 2
naming convention 9
borrowing Constants 22

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top