|
发表于 2020-6-14 18:40:47
|
显示全部楼层
又臭又长的代码:
- class Testimony:
- def __init__(self,sayer,subject,pred,obj):
- self.sayer = sayer
- self.subject = subject
- self.predicate = pred
- self.obj = obj
- self.value = False
- def result(self,answer):
- if self.subject == answer.subject and self.predicate == answer.predicate:
- self.value = True
- elif self.subject != answer.subject and self.predicate != answer.predicate:
- self.value = True
- else:
- self.value = False
-
- t1=Testimony('甲','甲',False,'thief')
- t2=Testimony('乙','甲',True,'thief')
- t3=Testimony('丙','丙',False,'thief')
- t4=Testimony('丙','乙',True,'thief')
- for thief in ('甲', '乙', '丙', '丁'):
- answer = Testimony('answer',thief,True,'')
- tru = 0
- for t in (t1,t2,t3,t4):
- t.result(answer)
- if t.value:
- tru += 1
- if tru == 1:
- print ("answer is :",thief)
复制代码
答案:
answer is : 丙 |
|