In number theory, the ruler function of an integer
For either definition of the ruler function, the rising and falling patterns of the values of this function resemble the lengths of marks on rulers with traditional units such as inches.
In advanced mathematics, the 0-based ruler function is the 2-adic valuation of the number,[1] and the lexicographically earliest infinite square-free word over the natural numbers.
[2] It also gives the position of the bit that changes at each step of the Gray code.
[4] A simulation of the puzzle, in conjunction with other methods for generating its optimal sequence of moves, can be used in an algorithm for generating the sequence of values of the ruler function in constant time per value.