Playful puzzle

Discussion in 'Java' started by Roedy Green, Oct 9, 2011.

  1. Roedy Green

    Roedy Green Guest

    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.
     
    Roedy Green, Oct 9, 2011
    #1
    1. Advertising

  2. Roedy Green <> wrote:
    > 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.
     
    Andreas Leitgeb, Oct 10, 2011
    #2
    1. Advertising

  3. Roedy Green

    Daniel Pitts Guest

    On 10/9/11 3:45 AM, Roedy Green wrote:
    > 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 :)
     
    Daniel Pitts, Oct 10, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Teigrob
    Replies:
    3
    Views:
    6,659
    Nedu N
    Aug 6, 2003
  2. dwa

    Design Puzzle!

    dwa, Jun 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    373
    Cowboy \(Gregory A. Beamer\) [MVP]
    Jun 10, 2004
  3. Shankara Narayanan

    Booking puzzle....

    Shankara Narayanan, Jun 17, 2004, in forum: ASP .Net
    Replies:
    20
    Views:
    938
    bredal Jensen
    Jun 30, 2004
  4. VB Programmer
    Replies:
    2
    Views:
    432
    Alan Lambert
    Nov 4, 2004
  5. Daniel Fetchinson

    playful coding problems for 10 year olds

    Daniel Fetchinson, Nov 1, 2010, in forum: Python
    Replies:
    9
    Views:
    349
Loading...

Share This Page