We use habracommentation as a Turing machine

    How did it even get into my head?



    Each habrakommentarii has its own address. The structure of the comment address:
    habrahabr.ru/blogs/gtd/135090/#comment_4486120
    Before “#”, this is a link to the topic, and after that, an anchor indicating the position of the comment on the page.
    If you specify links to other comments in the comments, and then click on them, the page will scroll to the desired location. Also, the comments themselves have a couple of arrows ↑ ↓ that allow you to move between replies to comments.
    “Hey!” I thought, “there is something in it.” At first, I thought about the limit of the confusion of comments, if they put links to each other. But then I realized that there is generally something from elementary programming, very much like a Turing machine. But some details were not enough, and I did not want to use the links in the content of the comments. Help came to your favorites!

    Implementation of the algorithm for adding unary numbers on a Turing machine


    To start, I trained on the Javascript version of the Turing machine http://matinf.igpu.ru/simulator/tm.html , summarized 2 and 3.
    01101110 -> 01111100

    Wrote a small algorithm for these purposes:
    
    0q1->0q2R
    1q2->1q2R
    0q2->1q3R
    1q3->1q3R
    0q3->0q4H
    0q4->0q4L
    1q4->0q5L
    1q5->1q5L
    0q5->0STOP
    

    We select tree-like comments and add two posts to our favorites and then 3 more posts:


    And now briefly the steps themselves (not all):

    As a result, we get what we wanted: 2 + 3 = 5. It is

    so simple and easy to perform arithmetic operations using just comments habrazhiteli.

    List of sources used



    Also popular now: