|
发表于 2022-11-26 17:17:33
|
显示全部楼层
本楼为最佳答案
 这题有解吗?我试了好像无解,也可能我的代码有错吧  
- def Condition_1(_1, _8, _2, _4, _5):
- if _1 == _8 and _1 not in [_2, _4, _5]:
- return "A"
- elif _1 == _2 and _1 not in [_8, _4, _5]:
- return "B"
- elif _1 == _4 and _1 not in [_8, _2, _5]:
- return "C"
- elif _1 == _5 and _1 not in [_8, _2, _4]:
- return "D"
- else: return False
- def Condition_2(_2, _3, _5, _6, _7, _9, _10):
- if _3 == _5 and _2 != _7 and _5 != _6 and _9 != _10:
- return "A"
- elif _2 == _7 and _3 != _5 and _5 != _6 and _9 != _10:
- return "B"
- elif _5 == _6 and _3 != _5 and _2 != _7 and _9 != _10:
- return "C"
- elif _9 == _10 and _3 != _5 and _2 != _7 and _5 != _6:
- return "D"
- else: return False
- def Condition_3(_3, *arr):
- if sum([each == _3 for each in list(arr)]) == 2:
- return "A"
- elif sum([each == _3 for each in list(arr)]) == 5:
- return "B"
- elif sum([each == _3 for each in list(arr)]) == 4:
- return "C"
- elif sum([each == _3 for each in list(arr)]) == 6:
- return "D"
- else: return False
- Condition_4 = lambda answer: answer
- Condition_5 = Condition_1
- Condition_6 = Condition_4
- def Condition_7(*arr):
- arr = list(arr)
- res = 0
- for i in range(9):
- if arr[i] == arr[i + 1]:
- res += 1
- D = "DBA_C"
- return D[res] if res in [2, 1, 4, 0] else False
- def Condition_8(*arr):
- if 'A' not in arr:
- return "A"
- elif 'B' not in arr:
- return "B"
- elif 'C' not in arr:
- return "C"
- elif 'D' not in arr:
- return "D"
- else: return False
- def Condition_9(*arr):
- res = 0
- for answer in "ABCD":
- if list(arr).count(answer) < 4:
- res += 1
- D = "_ABCD"
- return D[res] if res in [1, 2, 3, 4] else False
- def Condition_10(_3, _4, _9, _10):
- if _3 != _4 and (_4 == _9 == _10):
- return "A"
- elif _3 != _4 and (_3 == _9 == _10):
- return "B"
- elif _9 != _4 and (_3 == _4 == _10):
- return "C"
- elif _10 != _4 and (_3 == _4 == _9):
- return "D"
- else: return False
- for _1 in "ABCD":
- for _2 in "ABCD":
- for _3 in "ABCD":
- for _4 in "ABCD":
- for _5 in "ABCD":
- for _6 in "ABCD":
- for _7 in "ABCD":
- for _8 in "ABCD":
- for _9 in "ABCD":
- for _10 in "ABCD":
- if Condition_1(_1, _8, _2, _4, _5) and Condition_2(_2, _3, _5, _6, _7, _9, _10) and Condition_3(_3) and Condition_4(Condition_2(_2, _3, _5, _6, _7, _9, _10)) and Condition_5(_5, _2, _4, _1, _10) and Condition_6(_6) and Condition_7(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) and Condition_8(_2, _3, _4, _5, _6) and Condition_9(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) and Condition_10(_3, _4, _9, _10):
- print(Condition_1(_1, _8, _2, _4, _5), Condition_2(_2, _3, _5, _6, _7, _9, _10), Condition_3(_3), Condition_4(Condition_2(_2, _3, _5, _6, _7, _9, _10)), Condition_5(_5, _2, _4, _1, _10), Condition_6(_6), Condition_7(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), Condition_8(_2, _3, _4, _5, _6), Condition_9(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), Condition_10(_3, _4, _9, _10))
复制代码 |
|