arry = [["a",3.0,3], ["b",4.0,4], ["c",5.0,5]]
I am looking for the following output
[["a", 3.0, [["b", 4.0, 7], ["c", 5.0, 8]]],
["b", 4.0, [["a", 3.0, 7], ["c", 5.0, 9]]],
["c", 5.0, [["a", 3.0, 8], ["b", 4.0, 9]]]]
This is what I have done
- With the size of the array, I iterated over the loop
- First, I have taken the first element.
- Deleted it and made a new array. I iterated through the new array, calculated the sum and pushed the elements to new array2
- I added the deleted element at the end
I am not able to produce the following above mentioned format of the output. The output I am able to do is
[a,3.0,b,4.0,7]
7 here is 3+4
[a,3.0,c,5.0,8]
[b,4.0,c,5.0,9]
..etc
Apart from that, how to code to display lets say only the elements less than 8
and get this output
[["a",3.0,["b",4.0,7]],["b",4.0,["a",5.0,7]],["c",5.0,[]]