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.
$$ \frac{1}{2} < \left\lfloor \text{mod}\left( \left\lfloor \frac{y}{17} \right\rfloor 2^{ -17 \lfloor x \rfloor -\text{mod}\left( \lfloor y \rfloor ,17 \right) } ,2 \right) \right\rfloor $$
where \$\lfloor\cdot\rfloor\$ is the floor function.
Let \$k\$ be the following 543-digit number:
960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719
If one graphs the set of points \$(x, y)\$ in \$0 \le x < 106\$ and \$k \le 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):
So what?
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.
Test Images
[ ] should produce ~1.4946x10542
[ ] should produce ~7.2355x10159
[ ] should produce 21801 * 17
[ ] should produce (21802-1) * 17
Check out this Gist for the exact solutions.
This is code-golf, so least number of bytes wins.
Helpful Links
quine
somewhere. \$\endgroup\$