by guessmyname · 10y ago · 0 comments
As I read, numbers I see. 'Twould be a shame not to
count this art among the great texts of our time
2. Threshold so some of the pixels are black and others are white. Save as ASCII PBM.3. Strip the PBM header lines and remove newlines so that it's just 0's and 1's.
4. Now feed it through this program:
#include <stdio.h>
main() {
int c, l=0, n=1;
while(EOF != (c=getchar())) {
if(c == l) n++;
else {
putchar(n);
n=1;
}
l = c;
}
putchar('\n');
return 0;
}
Output is the following: 43-6F-6E-67-72-61-74-75-6C-61-74-69-6F-6E-73-2C-20-79-6F-75-20-73-6F-
6C-76-65-64-20-74-68-65-20-70-75-7A-7A-6C-65-21-20-57-68-79-20-64-6F-
6E-92-74-20-79-6F-75-20-61-70-70-6C-79-20-74-6F-20-6A-6F-69-6E-20-6F-
75-72-20-74-65-61-6D-3F-20-6D-69-35-2E-67-6F-76-2E-75-6B-2F-63-61-72-
65-65-72-73-20
5. This smells like ASCII, let's decode it with tr -d - | xxd -p -r> Congratulations, you solved the puzzle! Why dont you apply to join our team? mi5.gov.uk/careers
From: https://archive.rebeccablacktech.com/g/thread/52888920#p5289...
Still, my solution (in JS) was a little more verbose than yours...
<img src="puzzle2.png" id="puzzle-image">
<script>
/*
Pink (white) 232,3,138
Blue (black) 58,185,229
*/
window.addEventListener("load", function() {
var image = document.getElementById("puzzle-image"),
canvas = document.createElement("canvas"),
context = canvas.getContext("2d");
canvas.width = image.width;
canvas.height = image.height;
context.drawImage(image, 0, 0, image.width, image.height);
// Test 1 - rle
(function() {
var rle = [], prev = null, count = 0;
for (let y = 0; y < image.height; y++) {
for (let x = 0; x < image.width; x++) {
let pd = context.getImageData(x, y, 1, 1).data;
if (prev === null) {
prev = pd[0];
}
if (pd[0] == prev) {
count++;
} else {
rle.push(count);
count = 1;
prev = pd[0];
}
}
}
var r1 = "";
for (let i = 0; i < rle.length; i++) {
r1 += String.fromCharCode(rle[i]);
}
console.log(r1);
var r2 = "";
for (let i = 0; i < r1.length; i += 3) {
r2 += String.fromCharCode(parseInt(r1[i] + r1[i + 1], 16));
}
console.log(r2);
}());
}, false);
</script>
(Where puzzle2.png is the image in black & white)(Edited to fix indentation...)
#!/bin/sh
wget https://www.mi5.gov.uk/sites/default/files/u2/puzzle.png
convert puzzle.png puzzle.xpm # Convert the image to XPM with ImageMagick.
# Here is what the contents of puzzle.xpm looks like:
# http://pastebin.com/0PySSAXx. The spaces represent one color and the dots
# the other. We'll replace the spaces with underscores for readability.
<puzzle.xpm tr ' ' _ \
| tr -d "\n" \
| sed -e 's|","||g; s|^.*\*/"||; s|".*$|| # Remove metadata, C framing.' \
| sed -e 's|_\.|_\n.|g; s|\._|.\n_|g # New line on color change. ' \
| awk '{printf "%c", length($0)}' \
| xxd -r -p
The XPM image file format (https://en.wikipedia.org/wiki/X_PixMap) is great for doing things like this. I find it easier to read and to edit by hand than the Netpbm format family. It seems ImageMagick can't write XPM2, though, which makes extra preprocessing necessary.