PiSAYISI
An experimental Django project that maps the digits of pi to letters and searches for meaningful words.
PiSAYISI is a Django project I wrote in November 2016 for pisayısı.com. I built it to turn the digits of pi into letters, colours, coordinates and charts in different ways and to publish the results as articles on the site. The project is an experiment made partly out of curiosity and partly for fun; it also became a place where I tried out different ways of writing code with Python and Django.
Purpose
The digits of pi go on forever without repeating. When those digits are turned into letters according to some rule, it may be possible to find familiar words, or even meaningful sentences, among them. This idea kept me busy for a long time and I wanted to gather my experiments in one place. The method I found most interesting was matching the digits to Hebrew letters. Alongside these experiments, I also collected general information about pi on the site under categories.
How it works
The site's content is organised in three levels: categories, subcategories and topics. Every topic has a title, an author, HTML content and a link generated automatically from the title. I enter the content through the Django admin with the TinyMCE editor. Addresses take the form /category/kategorisi/, /category/subcategory/konusu/ and /category/subcategory/topic/konu-detayi/.
Some topics open a working page instead of a fixed article. The topic whose link contains canvasjs charts the first digits of pi with CanvasJS. The visitor can choose how many digits to see and whether to draw a line, area, column or pie chart; next to the chart, the number of times each digit from 0 to 9 appears is also shown. The topic whose link contains paperjs shows an interactive drawing experiment made with Paper.js.
Experiments
I did the actual calculations with small Python scripts in the static/py folder. The first 100,000 digits of pi are stored in a text file, and the scripts read from that file.
pi_replace.pyturns numbers into letters according to the numerical values of the Hebrew alphabet. Values such as Alef 1, Yod 10 and Kuf 100 are used, and larger values are matched first. The result was written to separate files, both with the letter names and with Hebrew characters.pi_hexrenk.pygroups the digits six at a time, uses each group as a colour code and produces a coloured table from the first 3,000 digits.pi_latlong.pybuilds latitude and longitude values from the digits and turns each pair into a Google Maps link.pi_toplacikart.pyalternately adds and subtracts the digits in order and writes out the running totals.pi_kactanevar.pycounts how often each digit appears, andpi_datapoints.pyprepares the data points for the chart.pi_bul.pytries to compute pi with an arctangent series and high-precision numbers.
Technical background
The project was written with Python 2 and Django and uses a MySQL database. I used Django Suit for the admin panel and django-tinymce for editing content. The charts are made with CanvasJS and the drawing experiment with Paper.js. For computing pi I relied on the gmpy2 library. The repository also includes a sample Apache configuration file, a robots.txt and a sitemap.xml.
- Category
- Websites
- Year
- 2016
Technologies
- Python
- Django
Links
- GitHub https://github.com/muslu/PiSAYISI