Skip to content

Instantly share code, notes, and snippets.

@Spuffynism
Last active February 5, 2018 21:28
Show Gist options
  • Save Spuffynism/8be1ddde3c1ceea547d2cd8b554899fa to your computer and use it in GitHub Desktop.
Save Spuffynism/8be1ddde3c1ceea547d2cd8b554899fa to your computer and use it in GitHub Desktop.
prints tupper formula's k value
<script>
// tupper formula's k value, in binary
var kbin = "00110010101000100001010101011111000010010010100000000000000000000000000000001000000000000000101000000000000010001000000000000000000000001111111111111111110000000000000000100000111100000000000000001000000000000011100000000000000000100000000000001110000000000000000000000000000000011000000000000001001000000000000010010000000000000011000000000000000000000000000000001100000000000000100100000000000001001000000000000011111100000000000000000000000000011111110000000111000000011100110000000000000110000000000000000011111111111111110100000000000000001011111010000000000000000101011000001100101001000001000111010001100010000000000000000111111111111111100000000000000000000000011001000000000000101001000000000001001010000000000010001000100000000000000001000000000000000000000000000000011111000000000000000000000000000001100100000000000000111000000000000000000000000001111111100000000010000000000000000100101000000000000000100000000000010010100000000000100000000000000001111111100000000000000000000000000000001000000000000000010000000000000000000000000000000111000000000000000010000000000000011100000000000000001000000000000001100000000000000000000000000000000111000000000000001010000000000000011100000000000000000000000000000001110000000000000010100000000000000111110000000000000000000000000000111100000000000110000110000000000000000000000000011111111000000000100000000000000001010110000000000000010000000000000100011000000000001000000000000000011111111000000000000000000000000001000000000000000001100000000000000000000000000000000001111100000000000000000000000000000110010000000000000011100000000000000000000000000110000110001000000011110000001100000000000000000000000000000000001100100000000000010100100000000000100101000001100001000100001100111000000011100100001111111000001000000000000000011111111111111111";
// formats a row of the picture
var format = row => {
var formatted = row.map(bit => bit === "0"
? "<span style=\"color:yellow\">0</span>"
: "<span style=\"color:blue\"><b>1</b></span>");
return formatted.join("") + "<br>";
}
// transposes a matrix
var transpose = a => Object.keys(a[0]).map(c => a.map(r => r[c]));
// split the number into 17 characters length columns
var pictureBits = kbin
.match(/.{1,17}/g)
.map(column => column.split(""));
// transpose the resultant matrix so that the picture is "along" the x axis instead of the y axis
var transposedPictureBits = transpose(pictureBits);
// reverse the picture rows so that the picture is not upside-down and format it
var picture = transposedPictureBits
.reverse()
.map(format)
.reduce((acc, v) => acc + v, "");
// show Tupper's formula
document.write(picture);
</script>
<style>
* {
font-family: monospace;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment