Finding Waldo in π
kundor.github.io
kundor.github.io
Hmm. I don't know that I agree. There are certainly more objective choices here than just picking any old palette, and in fact there are choices where it's not obvious the result should be considered a "palette" at all.
For example, the obvious choice to me is to treat the π bitstream as 8 bit RGB data like you would see in the PPM image format. In other words, one pixel at a time, each 8 bits represents a number from 0-255 for the red, green, and blue channel in that pixel respectively.
Of course that's a much harder ask since the colors are in this case not arbitrary, but you could (and should!!) still cheat at this by arbitrarily selecting the width of the resulting rows of pixels.
I'm not mad at seeing this palette based solution to the problem though, it's a very fun hack! Probably doing it for real would take an impossible amount of CPU time. Maybe if you did 4-bit RGB values it would be possible?
There's no doubt it's a much more objective choice than the one I used! I did say I was cheating.
Going to 4-bit color won't make it feasible. Even with 1-bit black/white pixels on about the minimum possible 18x24 Waldo face, you have 432 bits to look for, and you're not going to find them without cheating somehow. This guy on Twitter tried pretty thoroughly: https://twitter.com/gsuberland/status/1508697913177915393
For the palette hack, you want to go the other way; it's easier with bigger pixels. I was able to create a perfect Waldo face from the first 988 bytes of π as a TIFF, where the standard supports 16-bit palette indices for the pixel data. Unfortunately nothing except imagemagick seems to support actually viewing these TIFFs.
[1] https://en.wikipedia.org/wiki/List_of_monochrome_and_RGB_col...
I can sort of think of:
1) Collapse the colours in the palette to the minimum necessary to be seen as "Waldo". The more slack in the gif palette the better - 24bit colour vs 16 colours (or fewer) in the starting image?
2) For each substring in Pi, map the hex value to a colour (or close to the colour) to match the expected image.
3) find best match - how?
How to backtrack though?
Perhaps pin important fragments?
The glasses and chin seem more important?
We're looking for a substring with the largest number of unique values. If we have unique values, we can paint each value with a colour close enough to the expected value that humans will see them as the same.
Maybe?
What I do is search for substrings with the fewest repeated bytes that don't match the target pattern. I prioritize first minimizing conflicts between light (white and tan) vs. dark (black and red). Reducing other conflicts is a tie-breaker.
The featured gif has 79 "mismatched" pixels out of 494, by the black/white metric. I've found candidates with as few as 75, but subjectively I didn't think they looked as good.
(The idea is basically that each consecutive 988 bytes gets put into an individual 19x26 8 bit image with your color palette, and these are then stacked in row order.)
The preview is not as pretty as the real thing, but I thought embedding a 27MB video in the page might be a bit much.
Here's one lossless frame from near the end of the video, it's kinda nice because it gives you a little bit of context for the final Waldo without being overwhelming. https://i.imgur.com/wNZICnP.png
Here's also the full image as a 21.2 MiB PNG: https://ipfs.io/ipfs/QmUJaeon4KjE2RGVirXTG5xQuA6pCWV5T9GW2KS...
The full image contains the first 99969546 digits of pi, including the opening 3.
So often, people observe patterns in nature that appear to be so unlikely as to be by design. I have family members that are superstitious: if a light flickers at the same time that they mention a recently deceased loved one, it must be "a sign". Similarly, they will point to some overwhelmingly unlikely occurrence in the news, and ask, "how do you explain that?" The answer is usually random chance (if not deceit). And this exercise is a good illustration of that.
"Waldo, in the digits of pi?!? What are the odds??" - To the outsider who is not scientifically minded, this just looks so coincidental as to be magic. But almost any pattern can be found in randomness. It's just that the size of the necessary search space explodes as the query becomes larger / more specific.
The average HN reader knows all this, but the Waldo story is still a cool way to describe it to other people.
If one cared to find "something apparently significant" in any moment, one would therefore find an infinity of them.
By comparison, events which are directly causally connected are diminishingly few, and mostly indistinguishable from those coincidences. Hence, most things are actually unknowable, and what few beyond the ordinary, require extremely expensive and technologically advanced science to uncover.
Assuming pi is normal [1], the probability of any bit string occurring in pi is 1.
Off course, pi isn't proven to be normal (containing all possible sequences of decimal digits, if I remember that correctly) yet so this thought experiment needs an encoding aware of that to work, and any random bit source that unrepeatingly explores the combinatorial space of a symbolic alphabet would work, pi is not special here at all. This is just the library of babel + encoding arbitary data structures into numbers.
As you say, finding patterns is not hard, it's unsurprising that random strings contain those things, maximum-entropy information sources maximize the expected information as per Shannon. The whole point, though, is finding useful patterns: things that predict other things you care about, which you didn't know beforehand (or just knew in vague outlines), and which are cheaper to find and explore than simply directly observing/simulating the things they predict. None of this holds for the 'patterns' you will find in a typical library of babel. Evolution and evolutionary algorithms can be seen as a tool to cull the impossibly large search space of a library of babel. Also mental heuristics like Occam's razor can be seen as tree-pruning heuristics this way.
An even more beautiful idea than "An infinite random string contains all possible data structures" is "An infinite random string contains all possible programs and all possible computations (according to all possible semantics of those programs)", explored by the legendary Greg Egan in Permutation City. I can't do justice to Egan in this already too-long-of-a-comment, but I promise you will absolutely be mind blown.
[1] https://slate.com/technology/2013/04/pi-meme-on-reddit-and-g...
Not quite. Although this is a popular misconception. It depends on the cardinality of randomness and the distribution that you're talking about.
As a casual example, an infinitely long randomly distributed sequence of set { A, B, C, D } will never contain the string "bkyiuuMbF."
You can take this example and apply it to other spaces. For instance, we may live in a universe where there really is no other set of possible interactions where life exists somewhere else in this supercluster. Maybe in a another one, though?
There are nearly 8 billion people on the planet at the time of writing, I think. There's a lot of random people in there, but only one you!
And yes, my web site looks like it was built 20 years ago and then allowed to rot ever since, since that is in fact what happened!
https://whiteis.com/whiteis/personal/programs/Pi/pi_images.s...
https://whiteis.com/whiteis/personal/programs/Pi/index.shtml
It's been a long time since I read Contact. Are the aliens supposed to have hacked the geometry of the universe to make the pattern show up in π?
>No problem, the locations are just metadata! Your files are still there, sitting in π - they're never going away, are they?
This deeply reminds me of Carl Sagan's science fiction novel, Contact.
(spoilers to the novel follow, so avoid if you haven't read it)
The film adaptation missed out on so much, and the treatment of pi is one such unfortunate omission (or simplification).
The novel's aliens were advanced, but they told the main character that even they were stumped by the clear messages left encoded deep within the universe's constants.
It made the ending to the book so much more profound and touching than the film.
Carl was a master of making us feel small, all the while opening up our imaginations to infinities beyond measure.
I feel this should not be possible, but I don't know how to proove it without a circular argument about entropy.
On the other hand, if you make a string of common byte sequences, a couple GB long, and distribute it with every PC... then you surely can achive hyper compression with some clever indexing (if you don't count the magic string to the compressed size, of course).
Of course this only works when you're limiting yourself to a subset of all possible data (in this case, the uppercase alphabet). A general method where all possible binary combinations are indexed (and the indexes are sent rather than the data) would not save any data as the binary data would always be its own index.
1) Take target image
2) Find the index in π (say) where a matchable sequence of bytes occur, like for Waldo. (If your image is big, this could take several years of computation time.)
3) Transmit the palette, width, height, and index: about 800 bytes.
4) Probably the index is too far out for everyone to have a copy of the data already (it would be beyond terabytes). So the recipient then spends several years computing the number out far enough.
5) Profit!
Note: the palette is optional; you could leave it out and only transmit about 32 bytes. Using a palette also means lossiness, because you're reducing to 256 colors and making compromises between pixels. But using one saves you several orders of magnitude of computation time.
(That is, the vast majority of possible images are "color noise" which all look more or less the same.)
This is what brotli does.
Since a hexadecimal digit is 4-bit long, I guess we should be able to locate 4x more Waldos if we allow solutions to be start in the middle of a hex digit?
> The pixel data in this gif are the 23,074,248th through 23,075,235th hexadecimal digits of π! (Equivalently, the 184,593,977th through 184,601,880th bits).
The author assumes a hex digit is 8-bit long here btw.
Yes, I did only search at 4-bit aligned bytes. Doing otherwise would be more complicated, much harder for others to easily verify from the downloadable hex digit data file, and not really more likely to succeed. Looking further out is just as beneficial as looking at more offsets.
They do explain what they do: https://kundor.github.io/Cheating-images/
In that case I'd be cool to know the probability in finding a close enough image in that optimized space
In the candidate stream, byte 0 is 4. The error is minimised if byte 2 is also 4. The values of the bytes don't matter, just the patterns of which bytes have the same value.
I find their methodology for evaluating candidate Waldos to be as sufficient as any other.
What I mean is, they could certainly choose a much harder evaluation criteria and fail, but that's not much of a blog.
But they're not finding exact bytes, they're finding something that very vaguely looks like something very vague. It also helps a lot that it's a face and human brains are very good at identifying faces.
The number of 500 bytes that would "look like" waldo is a lot higher than 1.
You might be surprised to learn that π! (pi factorial) is a thing that makes sense
π! = 7.1880827289760327020821943451247587185593017639684371624100356994...
I converted the smallest valid GIF file[1] (35 bytes) into decimal number: 540959129019042423917857241427143195931235689921032801204995597056286563376232988672
It's nowhere to be found in PI :) I couldn't even find "GIF87a". So, fuzzy search seems to be a must.
[1] https://stackoverflow.com/questions/2570633/smallest-filesiz...
Ooh, did you search all the way to the end?
The GIF file as stored on disk has extra headers, and the pixel data's been compressed. So the whole file isn't found in the digits of π, just the pixel data itself.
I'd guess the chance of actually finding a correctly formatted full GIF file in contiguous bytes of π is effectively nil.
I think if we could prove Pi is normal, we could probably also prove your statement to be true (but I’m not sure about that)
To see that the converse does not always hold, you could take something like the Champernowne constant https://en.m.wikipedia.org/wiki/Champernowne_constant and pad it with 9s between each integer, ie
.192939495969798999109911991299...
so that you still contain every finite substring, but you have a >50% chance of a randomly selected digit being 9.
Edit: Weird. It is pi at least in the original article. The left and right tips are cut off for me on HN font.