【发布时间】:2016-09-22 12:09:25
【问题描述】:
这是(我认为)复杂性理论中的简单问题。
#Consider the language E over the binary alphabet
#consisting of strings representing even non-negative
#integers (with leading zeros allowed).
#I.e. E = {x | x[-1] == '0'}.
#
#Reduce E to the language {'Even'} by implementing
#the function R
def R(x):
#Code
def main():
#test cases
assert(R('10010') in ['Even'])
assert(R('110011') not in ['Even'])
if __name__ == '__main__':
main()
根据映射缩减 def:
“语言 A 是可还原到语言 B 的映射,写作 A ≤ mB,
如果有一个可计算函数 f : Σ ∗ −→Σ ∗ ,其中对于每个 w,
w ∈ A ⇐⇒ f (w) ∈ B。
函数 f 称为从 A 到 B 的约简。”
可计算的映射函数是 f(n) = 2n(或 Python 中的 x
【问题讨论】:
-
这是(我认为)家庭作业中的简单问题。
标签: python complexity-theory turing-machines