如果我有兩個列出了每個具有可以是兩個可能的值中的一個和兩個列表是除了一個值中,相同的元件,其方法我應該用來查找該值的索引?我要在Python作爲背景信息碼本有效的方法來找到單個不同元素的兩個列表之間的折射率在Python
方法A:
1. represent both lists as a binary literals
2. use XOR on the two binary literals to give a value "v" that is a power of 2
3. finally, use math.log(v, 2) to get the index
或方法B:
just iterate through both lists until a different element is found and
get the index
或使用Python另一種方式?
所以,如果你有'[1,2 ,3]'和'[1,2,4]'在兩個列表中獲取3和4的索引? – TerryA
它們是否已被列爲清單? – Jared
@Haidro是的,這就是我正在談論的例子 –