Golf the Chinese 9*9 multiple table
Stax, 66 characters
9mYF"得一二三四五六七八九"cacy*~@ny@\p;11AH:b!n;A/X@]z?px'十z?p,A%sn@]z?' +qD
Number of bytes depends on the encoding used for Chinese characters.
Run and debug online!
Explanation
9mYF...D Loop `n` times and print a newline after each loop, `n`=1..9
"..."cay*~@ny@\p
"..."c Push the string and duplicate it
ay Fetch the outer loop variable
* Multiply with the inner loop variable
~ Move the product to input stack for later use
@ Take character at the index specified by inner loop variable
ny@ Take character at the index specified by outer loop variable
\p Print the two characters
;11AH:b!n;A/X@]z?p
;11AH:b! ?p Is the product not in range [11,20)?
Output (*) if true, (**) if false.
n;A/X@ Character at the index of the "ten" digit of product
] Convert character to string (*)
z Empty string (**)
x'十z?p,A%sn@]z?' +q
x'十z?p Print "十" if the "ten" digit is non-zero, nothing otherwise
,A%sn@]z? Get the character specified by the last digit if that digit is non-zero, empty string otherwise
' +q Append a space and print
Alternative version (Stax 1.0.6), 59 bytes (by @recursive)
This uses a feature that is inspired by this challenge and is only included in Stax 1.0.6 which postdates the challenge.
éz░╖▐5à{│`9[mLùÜ•ëO╞îπl▼Γ─§╥|▒╛Δ◙Φµ'r╠eƒÿQ╫s♪Ω]£ï♪D3╚F◙δÿ%‼
The ASCII version is
9mX{x\_x*YA/]yA-y20<*!*+y9>A*+yA%]0-+"NT|,,t.%,p&()(!'^pq kzi !X6"!s@mJ
This version constructs the index array and then uses it to index the string of Chinese characters to avoid redundant stack operations (c
,a
,n
) and multiple @
s.
Explanation
9mX{...m Loop `n` times and map `1..n` to a list of strings, `n`=1..9
J Join the strings with space and print with a newline
x\_x*YA/]yA-y20<*!*+y9>A*+yA%]0-+"..."!s@
x\ A pair: (inner loop variable, outer loop variable)
_x*Y Product of inner and outer loop variable
A/ floor(product/10)
] [floor(product/10)]
yA- Product does not equal 10
y20< Product is less than 20
*! `Nand` of them
This is true (1) if the product is in the range {10}U[20,81]
* Repeat [floor(product/10)] this many times
This results in itself if the predicate above is true, or empty array if it is false
+ Add it to the list of [inner loop var, outer loop var]
This list will be used to index the string "得一二三四五六七八九十"
y9>A* Evaluates to 10 if the product is larger than 9, 0 otherwise
When indexed, they become "十" and "得", respectively
+ Append to the list of indices
yA% Product modulo 10
]0- [Product modulo 10] if that value is not zero, empty array otherwise
+ Append to the list of index
"..."! "得一二三四五六七八九十"
s@ Index with constructed array
Python 3, 151 149 146 bytes
-3 bytes thanks to Rod.
l=" 一二三四五六七八九"
for i in range(1,10):print([l[j//i]+l[i]+('得',l[j//10][10<j<20:]+'十')[j>9]+l[j%10]for j in range(i,i*i+1,i)])
Try it online!
Javascript, 190 bytes
(_="得一二三四五六七八九十")=>{for(i=1;i<10;i++){for(t="",v=0;v<i;t+=_[++v]+_[i]+[...(v*i+'')].map((a,b,c) => c.length>1&&b==0?(a>1?_[a]+'十':'十'):b==0?'得'+_[a]:_[a]).join``+' ');console.log(t)}}
a=(_=" 一二三四五六七八九")=>{for(i=1;i<10;i++){for(t="",v=0;v<i;t+=_[++v]+_[i]+[...(v*i+'')].map((a,b,c) => c.length>1&&b==0?(a>1||c[1]==0?_[a]+'十':'十'):b==0?'得'+_[a]:_[a]).join``+' ');console.log(t)}}
a()