Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The general overview of my solution would be:</p> <ol> <li>I start with calculating the maximum amount of raw data that you can fit into 140 utf8 characters. <ul> <li>(I am assuming utf8, which is what the original <a href="http://www.flickr.com/photos/quasimondo/3518306770/in/photostream/" rel="nofollow noreferrer">website</a> claimed twitter stored it's messages in. This differs from the problem statement above, which asks for utf16.)</li> <li>Using <a href="http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8" rel="nofollow noreferrer">this utf8 faq</a>, I calculate that the maximum number of bits you can encode in a single utf8 character is 31 bits. In order to do this, I would use all characters that are in the U-04000000 – U-7FFFFFFF range. (1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx, there are 31 x's, therefore I could encode up to 31 bits).</li> <li>31 bits times 140 characters equals 4340 bits. Divide that by 8 to get 524.5, and round that down to <strong>542 bytes</strong>.</li> <li>(If we restrict ourselves to utf16, then we could only store 2 bytes per character, which would equal 280 bytes).</li> </ul></li> <li>Compress the image down using standard jpg compression. <ul> <li>Resize the image to be approximately 50x50px, then attempt to compress it at various compression levels until you have an image that is as close to 542 bytes as possible without going over.</li> <li><a href="https://imgur.com/zikqe.jpg" rel="nofollow noreferrer">This is an example</a> of the mona lisa compressed down to 536 bytes.</li> </ul></li> <li>Encode the raw bits of the compressed image into utf-8 characters. <ul> <li>Replace each x in the following bytes: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx, with the bits from the image. </li> <li>This part would probably be the part where the majority of the code would need to be written, because there isn't anything that currently exists that does this.</li> </ul></li> </ol> <p>I know that you were asking for code, but I don't really want to spend the time to actually code this up. I figured that an efficient design might at least inspire someone else to code this up.</p> <p>I think the major benefit of my proposed solution is that it is reusing as much existing technology as possible. It may be fun to try to write a good compression algorithm, but there is guaranteed to be a better algorithm out there, most likely written by people who have a degree in higher math.</p> <p>One other important note though is that if it is decided that utf16 is the preferred encoding, then this solution falls apart. jpegs don't really work when compressed down to 280 bytes. Although, maybe there is a better compression algorithm than jpg for this specific problem statement.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload