How to resolve the algorithm Cistercian numerals step by step in the AutoHotkey programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Cistercian numerals step by step in the AutoHotkey programming language

Table of Contents

Problem Statement

Cistercian numerals were used across Europe by Cistercian monks during the Late Medieval Period as an alternative to Roman numerals. They were used to represent base 10 integers from 0 to 9999. All Cistercian numerals begin with a vertical line segment, which by itself represents the number 0. Then, glyphs representing the digits 1 through 9 are optionally added to the four quadrants surrounding the vertical line segment. These glyphs are drawn with vertical and horizontal symmetry about the initial line segment. Each quadrant corresponds to a digit place in the number: Please consult the following image for examples of Cistercian numerals showing each glyph: [1] Due to the inability to upload images to Rosetta Code as of this task's creation, showing output here on this page is not required. However, it is welcomed — especially for text output.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Cistercian numerals step by step in the AutoHotkey programming language

Source code in the autohotkey programming language

CistercianNumerals(num){
    x := []    
    ;UPPER LEFT      0     1     2     3     4     5     6     7     8     9
    x[1, "UL"] := ["000","111","000","000","100","111","100","111","100","111"]
    x[2, "UL"] := ["000","000","000","001","010","010","100","100","100","100"]
    x[3, "UL"] := ["000","000","000","010","001","001","100","100","100","100"]
    x[4, "UL"] := ["000","000","111","100","000","000","100","100","111","111"]

    ;UPPER RIGHT     0     1     2     3     4     5     6     7     8     9
    x[1, "UR"] := ["000","111","000","000","001","111","001","111","001","111"]
    x[2, "UR"] := ["000","000","000","100","010","010","001","001","001","001"]
    x[3, "UR"] := ["000","000","000","010","100","100","001","001","001","001"]
    x[4, "UR"] := ["000","000","111","001","000","000","001","001","111","111"]

    ;BOTTOM LEFT     0     1     2     3     4     5     6     7     8     9
    x[1, "BL"] := ["000","000","111","100","000","000","100","100","111","111"]
    x[2, "BL"] := ["000","000","000","010","001","001","100","100","100","100"]
    x[3, "BL"] := ["000","000","000","001","010","010","100","100","100","100"]
    x[4, "BL"] := ["000","111","000","000","100","111","100","111","100","111"]

    ;BOTTOM RIGHT    0     1     2     3     4     5     6     7     8     9
    x[1, "BR"] := ["000","000","111","001","000","000","001","001","111","111"]
    x[2, "BR"] := ["000","000","000","010","100","100","001","001","001","001"]
    x[3, "BR"] := ["000","000","000","100","010","010","001","001","001","001"]
    x[4, "BR"] := ["000","111","000","000","001","111","001","111","001","111"]

    num := SubStr("0000" num, -3)
    n := StrSplit(num)    ; n.1*1000 + n.2*100 + n.3*10 + n.4
    loop 4
        res .= x[A_Index, "UL", 1+n.3] . "1" . x[A_Index, "UR", 1+n.4] . "`n"
    loop 4
        res .= "0001`n"
    loop 4
        res .= x[A_Index, "BL", 1+n.1] . "1" . x[A_Index, "BR", 1+n.2] . "`n"
    res := StrReplace(res, 0, " ")
    res := StrReplace(res, 1, "#")
    return Trim(res, "`n")
}


Gui, font, S24, Consolas
Gui, add, Text, vE1 w150 r12
Gui, show, x0 y0
for i, num in [0, 1, 20, 300, 4000, 5555, 6789, 2022]
{
    GuiControl,, E1, % CistercianNumerals(num)
    MsgBox % num
}
return


  

You may also check:How to resolve the algorithm Polynomial long division step by step in the RPL programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Matrix multiplication step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Metered concurrency step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Input loop step by step in the Déjà Vu programming language