gpt4 book ai didi

python - 自然三元逻辑?

转载 作者:太空宇宙 更新时间:2023-11-03 12:15:30 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How can I find the missing value more concisely?

有没有一种很好的方式来表达字母表 a b c 上的交换运算符 T 使用Python 语言,其中

  • a T b == c
  • b T c == a
  • c T a == b

我最好的尝试是硬编码:

def T(first, second):
if first is 'a' and second is 'b':
return 'c'
if first is 'a' and second is 'c':
return 'c'
if first is 'b' and second is 'c':
return 'a'
if first is 'b' and second is 'a':
return 'c'
if first is 'c' and second is 'a':
return 'b'
if first is 'c' and second is 'b':
return 'a'

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com