Tupper's Self-Referential Formula (copied from Wikipedia)
Tupper's self-referential formula is a formula defined by Jeff Tupper that, when graphed in two dimensions at a very specific location in the plane, can be "programmed" to visually reproduce the formula itself. It is used in various math and computer science courses as an exercise in graphing formulae.
Where is the floor function.
k be the following 543-digit number:
If one graphs the set of points
(x, y) in
0 <= x < 106 and
k <= y < k + 17 satisfying the inequality given above, the resulting graph looks like this (note that the axes in this plot have been reversed, otherwise the picture comes out upside-down):
The interesting thing about this formula is that it can be used to graph any possible black and white 106x17 image. Now, actually searching through to search would be extremely tedious, so there's a way to figure out the k-value where your image appears. The process is fairly simple:
- Start from the bottom pixel of the first column of your image.
- If the pixel is white, a 0 will be appended to the k-value. If it is black, append a 1.
- Move up the column, repeating step 2.
- Once at the end of the column, move to the next column and start from the bottom, following the same process.
- After each pixel is analyzed, convert this binary string to decimal, and multiply by 17 to get the k-value.
What's my job?
Your job is to create a program which can take in any 106x17 image, and output its corresponding k-value. You can make the following assumptions:
- All images will be exactly 106x17
- All images will only contain black (#000000) or white (#FFFFFF) pixels, nothing in between.
There's a few rules, too:
- Output is simply the k-value. It must be in the proper base, but can be in any format.
- Images must be read from either a PNG or PPM.
- No standard loopholes.
[ ] should produce ~1.4946x10542
[ ] should produce ~7.2355x10159
[ ] should produce 21801 * 17
[ ] should produce (21802-1) * 17
This is code-golf, so least number of bytes wins.