📅  最后修改于: 2022-03-11 14:46:29.904000             🧑  作者: Mango
import numpy as np
def symmetrical_sum (arr):
l = len(arr)-1
bool_arr = np.array([x==arr[l-i] for i,x in enumerate(arr)])
idx_arr = np.where(bool_arr==True)[0]
if len(idx_arr):
res = arr[min(idx_arr):max(idx_arr)+1]
else:
res = []
return (res, sum(res))