/usr/share/texlive/texmf-dist/metapost/suanpan/abacus.mp is in texlive-metapost 2013.20140215-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | input suanpan
setup_abacus(N=13,NBL=5,NBU=2,bead="suanpan",units=0);
% initial value of a suanpan
beginfig(1);
rod_numbers:=false;
reset_abacus;
draw_abacus;
endfig;
setup_abacus(N=13,NBL=4,NBU=1,bead="soroban",units=1);
% initial value of a soroban
beginfig(2);
rod_numbers:=false;
reset_abacus;
draw_abacus;
endfig;
setup_abacus(N=13,NBL=5,NBU=2,bead="suanpan",units=0);
beginfig(3);
rod_numbers:=true;
reset_abacus;
valL[1]:=2;
valL[3]:=5;
valU[2]:=1;
valU[4]:=2;
draw_abacus;
endfig;
beginfig(4);
reset_abacus;
set_abacus_val("10552");
draw_abacus;
endfig;
beginfig(10);
reset_abacus;
valL[1]:=2;
valL[3]:=5;
valU[2]:=1;
valU[4]:=2;
draw_abacus;
endfig;
beginfig(20);
reset_abacus;
valL[1]:=3;
valL[3]:=5;
valU[2]:=1;
valU[4]:=2;
draw_abacus;
endfig;
% soroban?
beginfig(30);
setup_abacus(N=13,NBL=4,NBU=1,bead="soroban",units=1);
set_abacus_val("651324");
set_abacus_gray(deck="lower",below="000011",
above="000010");
set_abacus_gray(deck="upper",below="000001",
above="000010");
draw_abacus;
mark_abacus(i=1,j=5)(btex 1 etex);
mark_abacus(i=2,j=2)(btex 2 etex);
mark_abacus(i=2,j=3)(btex 3 etex);
endfig;
%show_val;
setup_abacus(N=13,NBL=4,NBU=1,bead="soroban",units=1);
set_abacus_val("651324");
reset_abacus_gray;
add_val(v="82363456",iv=100,fig=true);
%message "**********************************";
%show_val;
setup_abacus(N=13,NBL=5,NBU=2,bead="suanpan",units=0);
% detailing one of the addition cases
beginfig(200);
reset_abacus;
reset_abacus_gray;
set_abacus_val("82951324");
draw_abacus;
endfig;
beginfig(201);
set_abacus_val("82951324");
add_val(v="60000",iv=100,fig=false);
draw_abacus;
endfig;
%-------------------------------------------
beginfig(202);
reset_abacus;
reset_abacus_gray;
set_abacus_val("82951324");
set_abacus_gray(deck="lower",below="1010000",
above="0400000");
set_abacus_gray(deck="upper",below="0110000",
above="0000000");
draw_abacus;
endfig;
beginfig(203);
reset_abacus_gray;
add_val(v="60000",iv=100,fig=false);
set_abacus_gray(deck="lower",below="0400000",
above="1010000");
set_abacus_gray(deck="upper",below="0000000",
above="0110000");
draw_abacus;
mark_abacus(i=5,j=5)(btex 1 etex);
endfig;
% the following two commands enable a base-8 abacus
vbu:=4; % value of a bead in the upper deck
setup_abacus(N=13,NBL=3,NBU=1,bead="suanpan",units=0);
beginfig(300);
reset_abacus;
reset_abacus_gray;
set_abacus_val("3401256");
draw_abacus;
endfig;
beginfig(301);
add_val(v="1234",iv=100,fig=false);
draw_abacus;
endfig;
end
|