Skip to content

About

This repository is for code files related to Tupper's self referential formula

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Tupper_related_codes

This repository is for code files related to Tupper's self referential formula

Description of Scripts

reverse_tupper.py script when run presents user with a grid have height 17 cells and width 106 cells (all cells are square in shape). When the user clicks on a cell it changes colour. When the user clicks again on the same cell it comes back to its previous colour. The user can draw any two coloured pixelated drawing. After the drawing is completed the user can close the grid using the close button on the grid window. This will close the grid window and print on the terminal the value of N (the lower bound of the allowed value of y in the tupper's self referential formula i.e. N < y < N + 17) and exits. If the user then plots Tupper's formula for the range of y derived from N printed by this script, he will get back whatever he had drawn on the grid. In essence this script, encodes any two coloured pixelated image that can fit in 17pixels height and 106 pixels width into a decimal number which can then be used along with popular Tupper's formula to get back the image. The reverse_tupper.py script can be used to find the value of N from the Tupper's self referential formula for any two coloured pixelated image with height 17 pixels and width 106 pixels.

The code in reverse_tupper.py script was tested in Ubuntu Desktop 16.04 LTS with Python 3.5.2 and pygame version 1.9.3 but since it was created in haste it does not necessarily follow python best practises like pep 8, etc (Please forgive me for that!). Reference code for this script was taken from https://shreevatsa.wordpress.com/2011/04/12/how-does-tuppers-self-referential-formula-work/ and http://programarcadegames.com/python_examples/f.php?file=array_backed_grid.py

plot-tupper-py3.py script was tested in Ubuntu Desktop 16.04 LTS with Python 3.5.2 and matplotlib version 3.0.3 and is basically a python 3 version of a similar script provided at https://shreevatsa.wordpress.com/2011/04/12/how-does-tuppers-self-referential-formula-work/ which is written in python 2. When executed, this script first asks the user, the upper bound in the allowed range of x. Then it asks user the value of N (in N<y<N+17). If the user just wants to see the image of the formula itself then he can simply type 0 and press enter. However, if the user wants to see some other image then he should supply the value of N for that image (note that the image should only be 17 pixels in height). Once the number is given and enter key is pressed it will graph the formula in the asked range of x and y.

An Example

An example is presented below to help you decide when to use which script

Once you run reverse_tupper.py you will see a grid on which you can draw something as shown below: faces drawn on grid and once you close the grid, this script will print a big number on the terminal window as an output. The number printed for the above drawing will be: 18533164859418198251262755153227120713057485460111207530175727996991303015796024165679167112487261788044962109682778685576380797374117091387813058873585776844259862429478316393745666145956420642735908348032011731298054238046254122125048624368970337899864300595601253586802986600916993824794508616984607292055840144041229698866971087107830778640328787245718226805703702183031367825804468324093774863601826686304657929734071336957592850091088257770057359479086180883625903262690799796524110678206564079310659483789880223231239673794365489152

Now you can run plot-tupper-py3.py script and supply the big number generated by reverse_tupper.py when prompted. plot-tupper-py3.py script will plot Tupper's self referential formula with that big number as N in the range of y (i.e. N < y < N + 17). For the above number you will get: faces from matplot lib

About

This repository is for code files related to Tupper's self referential formula

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages