-
-
Save mokemokechicken/31448d8f3011a9a3783afd1a8e8f5356 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
問: | |
あなたは | |
1. この質問に「いいえ」と正しく答えるか | |
2. この質問に「はい」と間違って答えるか | |
3. 教師に1万円を支払うか | |
のいずれかですか? | |
----- | |
回答 問いが真 払うか? | |
矛盾がない: [True, True, True] | |
矛盾がある: [True, True, False] | |
矛盾がある: [True, False, True] | |
矛盾がある: [True, False, False] | |
矛盾がある: [False, True, True] | |
矛盾がある: [False, True, False] | |
矛盾がない: [False, False, True] | |
矛盾がある: [False, False, False] | |
""" | |
def main(): | |
check_answer() | |
def check_answer(): | |
for yes_or_no in [True, False]: | |
for totally_correct in [True, False]: | |
for you_will_pay in [True, False]: | |
args = [yes_or_no, totally_correct, you_will_pay] | |
if yes_or_no is True: | |
is_correct_answer = is_question_right(*args) | |
else: | |
is_correct_answer = not is_question_right(*args) | |
if is_correct_answer == totally_correct: | |
print("矛盾がない: %s" % args) | |
else: | |
print("矛盾がある: %s" % args) | |
def is_question_right(yes_or_no, totally_correct, you_will_pay): | |
args = yes_or_no, totally_correct, you_will_pay | |
return q1_true()(*args) or q2_true()(*args) or q3_true()(*args) | |
def q1_true(): # いいえ、と正しく答える | |
return lambda yes_or_no, totally_correct, you_will_pay: yes_or_no is False and totally_correct is True | |
def q2_true(): # はい、と間違って答える | |
return lambda yes_or_no, totally_correct, you_will_pay: yes_or_no is True and totally_correct is False | |
def q3_true(): # 1万円払う | |
return lambda yes_or_no, totally_correct, you_will_pay: you_will_pay is True | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment