So, I have a list of numbers
weird_list = [800153196,
946067665,
827629917,
868941741,
875745873,
926109150,
1353347195,
1003235074,
1053666891,
1442194993,
1924716858,
1060724069,
1182240731,
1646547575,
1215762661,
1520107722,
1512568609,
1534064291,
1549459216,
1773697582,
1853820087,
1696910852,
1563415785,
1692314635,
1627783113]
My goal is to obtain a 2d np.array of sum of each pair of this list.
Example:
weird_list = [1, 2, 3]
resulting_array = [[0, 1, 2],
[1, 2, 3],
[2, 3, 4]]
I wrote this function which works just fine for smaller numbers, but not necessary, because I tested on arrays with bigger numbers. The problem for this array it's that I am obtaining somehow negative numbers.
def array_sum(i_list):
i_array = np.array(i_list) # converts list to np.array
i_array_rs1 = i_array.reshape(1, -1)
i_array_rs2 = i_array.reshape(-1, 1)
i_array_rs_SUM = i_array_rs1 + i_array_rs2
print(i_array_rs_SUM) # prints the sum of reshaped arrays, which doesn't work for my input list
I also wrote tried for some examples with lists of smaller/bigger numbers
low_list = [0, 1, 2, 3]
ex_list = []
weird_list_div_10 = []
weird_list_mult_10 = []
for i in range(len(weird_list)):
ex_list.append(i)
weird_list_div_10.append(weird_list[i] // 10)
weird_list_mult_10.append(weird_list[i] * 10)
Source for full code : https://pastebin.com/pKpgEtUm