Gravity Digital Root Program

The following code is a Gravity ‘Digital Root’ program. The ‘digital root’ of a number is the number obtained by adding together its digits, and then repeating the process on the result until a single digit remains. This program works with the standard ASCII encoding of the digits 0 to 9.

(0,0) : 2

(1,1,1,1, 2)    ->  # :
(1,1,1,1,48)    ->  # : 48
(1,1,1,1,49)    ->  # : 49
(1,1,1,1,50)    ->  # : 50
(1,1,1,1,51)    ->  # : 51
(1,1,1,1,52)    ->  # : 52
(1,1,1,1,53)    ->  # : 53
(1,1,1,1,54)    ->  # : 54
(1,1,1,1,55)    ->  # : 55
(1,1,1,1,56)    ->  # : 56
(1,1,1,1,57)    ->  # : 57
(1,1,1,1,48) 48 -> 48 :
(1,1,1,1,48) 49 -> 49 :
(1,1,1,1,48) 50 -> 50 :
(1,1,1,1,48) 51 -> 51 :
(1,1,1,1,48) 52 -> 52 :
(1,1,1,1,48) 53 -> 53 :
(1,1,1,1,48) 54 -> 54 :
(1,1,1,1,48) 55 -> 55 :
(1,1,1,1,48) 56 -> 56 :
(1,1,1,1,48) 57 -> 57 :
(1,1,1,1,49) 48 -> 49 :
(1,1,1,1,49) 49 -> 50 :
(1,1,1,1,49) 50 -> 51 :
(1,1,1,1,49) 51 -> 52 :
(1,1,1,1,49) 52 -> 53 :
(1,1,1,1,49) 53 -> 54 :
(1,1,1,1,49) 54 -> 55 :
(1,1,1,1,49) 55 -> 56 :
(1,1,1,1,49) 56 -> 57 :
(1,1,1,1,49) 57 -> 49 :
(1,1,1,1,50) 48 -> 50 :
(1,1,1,1,50) 49 -> 51 :
(1,1,1,1,50) 50 -> 52 :
(1,1,1,1,50) 51 -> 53 :
(1,1,1,1,50) 52 -> 54 :
(1,1,1,1,50) 53 -> 55 :
(1,1,1,1,50) 54 -> 56 :
(1,1,1,1,50) 55 -> 57 :
(1,1,1,1,50) 56 -> 49 :
(1,1,1,1,50) 57 -> 50 :
(1,1,1,1,51) 48 -> 51 :
(1,1,1,1,51) 49 -> 52 :
(1,1,1,1,51) 50 -> 53 :
(1,1,1,1,51) 51 -> 54 :
(1,1,1,1,51) 52 -> 55 :
(1,1,1,1,51) 53 -> 56 :
(1,1,1,1,51) 54 -> 57 :
(1,1,1,1,51) 55 -> 49 :
(1,1,1,1,51) 56 -> 50 :
(1,1,1,1,51) 57 -> 51 :
(1,1,1,1,52) 48 -> 52 :
(1,1,1,1,52) 49 -> 53 :
(1,1,1,1,52) 50 -> 54 :
(1,1,1,1,52) 51 -> 55 :
(1,1,1,1,52) 52 -> 56 :
(1,1,1,1,52) 53 -> 57 :
(1,1,1,1,52) 54 -> 49 :
(1,1,1,1,52) 55 -> 50 :
(1,1,1,1,52) 56 -> 51 :
(1,1,1,1,52) 57 -> 52 :
(1,1,1,1,53) 48 -> 53 :
(1,1,1,1,53) 49 -> 54 :
(1,1,1,1,53) 50 -> 55 :
(1,1,1,1,53) 51 -> 56 :
(1,1,1,1,53) 52 -> 57 :
(1,1,1,1,53) 53 -> 49 :
(1,1,1,1,53) 54 -> 50 :
(1,1,1,1,53) 55 -> 51 :
(1,1,1,1,53) 56 -> 52 :
(1,1,1,1,53) 57 -> 53 :
(1,1,1,1,54) 48 -> 54 :
(1,1,1,1,54) 49 -> 55 :
(1,1,1,1,54) 50 -> 56 :
(1,1,1,1,54) 51 -> 57 :
(1,1,1,1,54) 52 -> 49 :
(1,1,1,1,54) 53 -> 50 :
(1,1,1,1,54) 54 -> 51 :
(1,1,1,1,54) 55 -> 52 :
(1,1,1,1,54) 56 -> 53 :
(1,1,1,1,54) 57 -> 54 :
(1,1,1,1,55) 48 -> 55 :
(1,1,1,1,55) 49 -> 56 :
(1,1,1,1,55) 50 -> 57 :
(1,1,1,1,55) 51 -> 49 :
(1,1,1,1,55) 52 -> 50 :
(1,1,1,1,55) 53 -> 51 :
(1,1,1,1,55) 54 -> 52 :
(1,1,1,1,55) 55 -> 53 :
(1,1,1,1,55) 56 -> 54 :
(1,1,1,1,55) 57 -> 55 :
(1,1,1,1,56) 48 -> 56 :
(1,1,1,1,56) 49 -> 57 :
(1,1,1,1,56) 50 -> 49 :
(1,1,1,1,56) 51 -> 50 :
(1,1,1,1,56) 52 -> 51 :
(1,1,1,1,56) 53 -> 52 :
(1,1,1,1,56) 54 -> 53 :
(1,1,1,1,56) 55 -> 54 :
(1,1,1,1,56) 56 -> 55 :
(1,1,1,1,56) 57 -> 56 :
(1,1,1,1,57) 48 -> 57 :
(1,1,1,1,57) 49 -> 49 :
(1,1,1,1,57) 50 -> 50 :
(1,1,1,1,57) 51 -> 51 :
(1,1,1,1,57) 52 -> 52 :
(1,1,1,1,57) 53 -> 53 :
(1,1,1,1,57) 54 -> 54 :
(1,1,1,1,57) 55 -> 55 :
(1,1,1,1,57) 56 -> 56 :
(1,1,1,1,57) 57 -> 57 :

Proof of function

By having a heavier particle at the origin, all particles start moving inwards. When the particles at (1,0), (0,1), (−1,0) and (0,−1) collide with this particle, a mass is read from the input.

Every collision after this consists of four or more particles hitting the origin. In an unbounded number of collisions, exactly four particles will hit the particle at the origin. When this happens, if there is more input a particle at the origin is created with mass representing the digital root of all the digits read so far. If there is no more input the program outputs the digit root and attempts to read the input, causing it to halt. In the other collisions, the particle at the origin has the greatest mass and is therefore replaced after the collision.

This article was last edited on 14th April 2007. The author can be contacted using the form below.
Back to home page
Bookmark with: