Live data from Hacker News

Can you build a recognizable World Map in under 500 bytes?

experimentlog.com

51–58 of 58 posts

Re: Can you build a recognizable World Map in under 500 bytes?

#51
post #20

Representation for this I came up with: Allocate one magic number for "start line with space" another for "start line with asterisk" then any other number means this many of the current character and then swap character. Then it's a matter of picking a suitable way to encode numbers into bits. I came up with groups of four bits. If the high bit is not set that is the number, if it is set then read an additional group…

> Allocate one magic number for "start line with space" another for "start line with asterisk" then any other number means this many of the current character and then swap character. The galaxy brain move would be to always arbitrarily start with one character, replace the two special numbers with a single "don't output any characters, just swap" number, and then... congratulations, you just reinvented CompuServe RLE…

While the idea of using RLE with implicit swapping is the same, everything else is different. I'm not sure it's better in this case. One thing my version did is that it had explicit linebreaks, this approach was chosen as the map in the article had lines of varying lengths. If you don't now you have to accomplish that some other way, e.g. explicitly fill the line up with spaces and some mechanism of communicating the width of the image.

I also think using a varint encoding is a big win over fixed-width.

Re: Can you build a recognizable World Map in under 500 bytes?

#53

I know this doesn't meet the spirit of the challenge, but... _,--', _._.--._____ .--.--';_'-.', ";_ _.,-' .'--'. _.' {`'-;_ .-.>.' '-:_ ) / `' '=. ) > {_/, /~) snd |/ `^ .'

U+1F5FA does it in 4 bytes! https://www.compart.com/en/unicode/U+1F5FA

Enhance!

Re: Can you build a recognizable World Map in under 500 bytes?

#54
post #17

I feel like this challenge would be a lot more interesting if the size of complete code needed to output the map were counted.

Both are interesting, my html file is 846 bytes and the actual map data pulled in is 445 bytes but a comment on my blog someone came down to 786 bytes and it looks like under 400 bytes of data for the map.

Re: Can you build a recognizable World Map in under 500 bytes?

#55

Its a fun challenge. I used https://squoosh.app to make a pretty good one. Mostly just a resize and then OxiPNG for compression. Managed a 124x62 black/white image. OP has a resolution of 195x53, so I had very similar, but slightly worse i think? mostly a different aspect ratio + map projection i think. playing with Squoosh.app is very fun, and you can very easily see how the jump from 500b to 1-2kb turns a map from…

great job, looks like you got it down to 786 bytes of html and under 400 for the map data. I like your approach.

Re: Can you build a recognizable World Map in under 500 bytes?

#58
post #10

I didn't know you could do this with fetch() and a data: URI: fetch('data:;base64,1ZpLsgIxCEXnrM...==').then( r => r.body.pipeThrough(new DecompressionStream('deflate-raw')) ).then( s => new Response(s).text() ).then( t => b.innerHTML = ' ' + t )

u don't need the first .then: https://github.com/piwodlaiwo/smallest-world-map/pull/1

mine is shorter

Post reply on HN