挑战
给定一个任意的2元组列表,并在其中一个元组中包含一个元素,则输出其“伙伴”,即给出a
和[(i,j),...,(a,b),...,(l,m)]
输出b
。您可以假定所有元组都是唯一的,并且元组中的所有元素都是字符串。进一步假设您同时没有(x,y)
和(y,x)
。
测试用例
Input Output
[("(", ")"), ("{", "}"), ("[", "]")], "}" "{"
[("I'm", "So"), ("Meta", "Even"), ("This", "Acronym")], "Even" "Meta"
[("I", "S"), ("M", "E"), ("T", "A")], "A" "T"
[("test", "cases"), ("are", "fun")], "test" "cases"
[("sad", "beep"), ("boop", "boop")], "boop" "boop"
最小字节获胜!
[a, b, c, d]
代替[(a, b), (c, d)]
。这将使我的回答减少很多字节。:P