論理関数からの出力のリストを受け取り、真理値表のためのLaTeXコードを出力するプログラムまたは関数を書く。
入力には小文字の a-z
というラベルを付け、出力には F
というラベルを付ける必要があります。入力のリストの長さは常に 2 ^ 25
よりも短くなります。つまり、入力の数は常に25より少なくなるため、入力名にアルファベットの小文字の文字を使用できます。
入力
A number n
of 入力s and list of length
2^n
of binary numbers which represents the 出力s of a
logical function.
出力
LaTeX code that produces the truth table for that function. 入力
and 出力 values should be centered in rows. There must be a line
between table header and its values and between 入力s and 出力, so the
code should be similar to that below.
begin{tabular}{c * |c}
<������������������������
�
入力:
2
[0, 0, 0, 1]
出力:
begin{tabular}{cc|c}
a & b & F \
hline
0 & 0 & 0 \
0 & 1 & 0 \
1 & 0 & 0 \
1 & 1 & 1 \
end{tabular}
LaTeXに表示されたときに次の真理値表が表示されます
一般的なルール
- This is code-golf,
so shortest answer in bytes wins. -
Default Loopholes are forbidden.
Charcoal, 70 bytes
≔tabularζζ{*θc|c}⸿⪫✂β⁰Iθ¹&⁰&F\⸿hline⸿Eη⁺⪫⁺⮌EIθI﹪÷κX²λ²⟦ι⟧&¦\⁰endζ
Try it
online! Link is to verbose version of code. Explanation:
≔tabularζ
重複を避けるために、この文字列を変数に保存します。
ζ{*θc|c}⸿
初期の tabular {* 2c | c}
行(2つまたは最初の入力
q
の値)を印刷します。
⪫✂β⁰Iθ¹&⁰&F\⸿hline⸿
Get the first q
letters from the predefined
variable b
and insert &
s between them,
then append the &F\
and also print
hline
on the next line.
Eη⁺⪫⁺⮌EIθI﹪÷κX²λ²⟦ι⟧&¦\
Loop over the characters in the second input. For each one, its
index is converted to binary with length q
, the
character is concatenated, the result is joined with
&
s and \
is appended. The resulting
strings are implicitly printed on separate lines.
⁰endζ
endtabular
を印刷します。 ( |
は、コードを挿入するための省略記号としての単なるセパレータです)。