Possible Duplicate:
How can I find the missing value more concisely?
Is there a nice way of expressing the commutative operator T
on the alphabet a
b
c
using the language of Python, where
a T b == c
b T c == a
c T a == b
My best attempt is to hardcode things:
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'