User:Jccsvq/Abacus diagrams and procedure tables

Abacus diagrams

edit

Using images

edit

Diagrams of this type:


Write caption here!
A B C D E F G H I K J L M
                             
9 18 9 0 0 1 0 0 0 0 9 9 9

may be tailored in this way

{| cellspacing="0" style="text-align:center"
|+ '''Write caption here!'''
|-
|
!A
!B
!C
!D
!E
!F
!G
!H
!I
!K
!J
!L
!M
|
|-
| [[ File:suanpan-lw.png|25px]]
| [[ File:suanpan-9.png|25px]]
| [[ File:suanpan-18.png|25px]]
| [[ File:suanpan-9.png|25px]]
| [[ File:suanpan-0.png|25px]]
| [[ File:suanpan-0.png|25px]]
| [[ File:suanpan-1.png|25px]]
| [[ File:suanpan-0.png|25px]]
| [[ File:suanpan-0.png|25px]]
| [[ File:suanpan-0.png|25px]]
| [[ File:suanpan-0.png|25px]]
| [[ File:suanpan-9.png|25px]]
| [[ File:suanpan-9.png|25px]]
| [[ File:suanpan-9.png|25px]]
| [[ File:suanpan-rw.png|25px]]
|-
|
|9
|18
|9
|0
|0
|1
|0
|0
|0
|0
|9
|9
|9
|
|}

or you can use this rudimentary AWK code:

BEGIN{
letras="ABCDEFGHIKJLMNOPQRSTUVWXYZ"
}
{
print "{| cellspacing=\"0\" style=\"text-align:center\"";
print "|+ '''Write caption here!'''";
print "|-";
print "|";
for(i=1;i<=NF;i++){
    print "!"substr(letras,i,1);  
    };
print "|";
print "|-";
print "| [[ File:suanpan-lw.png|25px]]";
for(i=1;i<=NF;i++){
    print "| [[ File:suanpan-"$i".png|25px]]";  
    };
print "| [[ File:suanpan-rw.png|25px]]";
print "|-";
print "|";
for(i=1;i<=NF;i++){
    print "|"$i;  
    };
print "|";
print "|}";
}

to automatically generate them from an input like:

9 18 9 0 0 1 0 0 0 0 9 9 9

txt-abacus

edit

Generated with https://github.com/jccsvq/txt-abacus. Work on my desktop but not on my mobile devices because of accessible fonts. It is better to forget them for now!

   9 18  8  0  0  1              9  9  9
╔═════════════════════════════════════════╗
║  │  │  │  ●  ●  ●  ●  ●  ●  ●  │  │  │  ║
║  │  │  │  │  │  │  │  │  │  │  │  │  │  ║
║  ●  ●  ●  │  │  │  │  │  │  │  ●  ●  ●  ║
╠═════════════════════════════════════════╣
║  ●  ●  ●  │  │  ●  │  │  │  │  ●  ●  ●  ║
║  ●  ●  ●  │  │  │  │  │  │  │  ●  ●  ●  ║
║  ●  ●  ●  ●  ●  │  ●  ●  ●  ●  ●  ●  ●  ║
║  ●  │  │  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ║
║  │  │  │  ●  ●  ●  ●  ●  ●  ●  │  │  │  ║
║  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  │  │  │  ║
║  │  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ║
╚═════════════════════════════════════════╝
   A  B  C  D  E  F  G  H  I  J  K  L  M  

Caption text
Header text Header text

   9 18  8  0  0  1              9  9  9
╔═════════════════════════════════════════╗
║  │  │  │  ●  ●  ●  ●  ●  ●  ●  │  │  │  ║
║  │  │  │  │  │  │  │  │  │  │  │  │  │  ║
║  ●  ●  ●  │  │  │  │  │  │  │  ●  ●  ●  ║
╠═════════════════════════════════════════╣
║  ●  ●  ●  │  │  ●  │  │  │  │  ●  ●  ●  ║
║  ●  ●  ●  │  │  │  │  │  │  │  ●  ●  ●  ║
║  ●  ●  ●  ●  ●  │  ●  ●  ●  ●  ●  ●  ●  ║
║  ●  │  │  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ║
║  │  │  │  ●  ●  ●  ●  ●  ●  ●  │  │  │  ║
║  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  │  │  │  ║
║  │  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ●  ║
╚═════════════════════════════════════════╝
   A  B  C  D  E  F  G  H  I  J  K  L  M  

Example

Translating abacus procedure tables to wikitables

edit

AWK code

edit
BEGIN {
    FS="|";
    print "{| class=\"wikitable\" style=\"font-family:Courier; line-height: 1.10em;\"";
    print "|+ Caption text";
    print "|-";
    print "! Abacus !! Comment";
}
{
    sub(/\ *$/,"",$1)
    gsub(/\ /,"\&nbsp;",$1);
    print "|-";
    print "| " $1;
    print "| " $2;
}
END {
    print "|}";
}

Example data

edit
 ABCDEFGHIJKLM|
    4567890123|Entering radicand starting in CD (first group)
  2           |First root digit in B
   -4         |Subtract square of B from first group
  2  567890123|Null remainder
  4  567890123|Doubling B. Appending next group to remainder
  41 567890123|5/4≈1, try 1 as next root digit
    -4        |Continue division by 41, subtract 1✕41 from EF
     -1|
  41 157890123|15 as remainder
  42 157890123|Double second root digit
  42 157890123|Append next group
  423157890123|157/42≈3, try 3 as next root digit
    -12       |Continue division by 423, subtract 3✕423 from E-H
     -06|
      -09|
  423 30990123|309 as remainder
  426 30990123|Double third root digit
  426 30990123|Append next group
     etc.|

Generated wiki code

edit
{| class="wikitable" style="font-family:Courier; line-height: 1.10em;"
|+ Caption text
|-
! Abacus !! Comment
|-
| ABCDEFGHIJKLM
| 
|-
|    4567890123
| Entering radicand starting in CD (first group)
|-
|  2
| First root digit in B
|-
|   -4
| Subtract square of B from first group
|-
|  2  567890123
| Null remainder
|-
|  4  567890123
| Doubling B. Appending next group to remainder
|-
|  41 567890123
| 5/4≈1, try 1 as next root digit
|-
|    -4
| Continue division by 41, subtract 1✕41 from EF
|-
|     -1
| 
|-
|  41 157890123
| 15 as remainder
|-
|  42 157890123
| Double second root digit
|-
|  42 157890123
| Append next group
|-
|  423157890123
| 157/42≈3, try 3 as next root digit
|-
|    -12
| Continue division by 423, subtract 3✕423 from E-H
|-
|     -06
| 
|-
|      -09
| 
|-
|  423 30990123
| 309 as remainder
|-
|  426 30990123
| Double third root digit
|-
|  426 30990123
| Append next group
|-
|     etc.
| 
|}

Generated table

edit

After changing caption:

Caption text
Abacus Comment
ABCDEFGHIJKLM
   4567890123 Entering radicand starting in CD (first group)
 2 First root digit in B
  -4 Subtract square of B from first group
 2  567890123 Null remainder
 4  567890123 Doubling B. Appending next group to remainder
 41 567890123 5/4≈1, try 1 as next root digit
   -4 Continue division by 41, subtract 1✕41 from EF
    -1
 41 157890123 15 as remainder
 42 157890123 Double second root digit
 42 157890123 Append next group
 423157890123 157/42≈3, try 3 as next root digit
   -12 Continue division by 423, subtract 3✕423 from E-H
    -06
     -09
 423 30990123 309 as remainder
 426 30990123 Double third root digit
 426 30990123 Append next group
    etc.