Tuesday, October 4, 2022
HomeMathDominoes in Unicode

Dominoes in Unicode


I used to be spelunking round in Unicode and located that there are assigned characters for representing domino tiles and that the characters are enumerated in a handy order. Right here is the code chart.

There are codes for representing tiles horizontally or vertically. And though, for instance, the 5-3 is identical domino because the 3-5, there are separate characters for representing the orientation of the tile: one for 3 on the left and one for five on the left.

Whenever you embody orientation like this, a domino turns into primarily a base 7 quantity: the variety of spots on one finish is the variety of 7s and the variety of spots on the opposite finish is the variety of 1s. And the order of the characters corresponds to the order as base 7 numbers:

0-0, 0-1, 0-2, …, 1-0, 1-1, 1-2, … 6-6.

The horizontal dominoes begin with the double clean at U+1F031 and the vertical dominoes begin with U+1F063, a distinction of 32 in hexadecimal or 50 in base 10. So you possibly can rotate a domino tile by including or subtracting 50 to its code level.

The next tiny Python perform provides the codepoint for the domino with a spots on the left (or high) and b spots on the proper (or backside).

    def code(a, b, broad):
        cp = 0x1f031 if broad else 0x1f063
        return cp + 7*a + b

We will use this perform to print a (3, 5) tile horizontally and a (6, 4) tile vertically.

    print( chr(code(3, 5, True )),
           chr(code(6, 4, False)) )

To my shock, my laptop had the fonts put in to show the outcomes. This isn’t assured for such excessive Unicode values.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments