Timeline for Ordering and summing elements of a list based on their indexes
Current License: CC BY-SA 3.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 31, 2015 at 13:54 | vote | accept | Enzo | ||
| Oct 23, 2015 at 21:11 | answer | added | user31159 | timeline score: 4 | |
| Oct 22, 2015 at 17:02 | comment | added | march | Let us continue this discussion in chat. | |
| Oct 22, 2015 at 17:01 | comment | added | Enzo | They're numbers, not lists. a, b, g and h are the elements of the original vector | |
| Oct 22, 2015 at 17:00 | comment | added | march | So you are summing all 16 elements in the four lists a, b, g, and h? | |
| Oct 22, 2015 at 16:58 | comment | added | Enzo | No, it's a three-element list, which has the two positions and the sum as elements. I do the sum within the list itself, once I've ordered it. | |
| Oct 22, 2015 at 16:57 | answer | added | march | timeline score: 4 | |
| Oct 22, 2015 at 16:55 | comment | added | march | Okay, sorry, one more question. When you do a+b+g+h, the result should be a 4-element list, is that correct? | |
| Oct 22, 2015 at 16:47 | comment | added | Enzo | Ok, I edited again, I hope it's clearer now | |
| Oct 22, 2015 at 16:45 | history | edited | Enzo | CC BY-SA 3.0 | added 204 characters in body |
| Oct 22, 2015 at 16:40 | comment | added | Enzo | Summing a+b+g+h means summing the elements which are indexed by the same position. In the end, I'll have a vector like {{-1,-1,a+b+g+h}, ... ,{1,1,j+k+y+z}}. So "summing" does not result in {-1,-1}, they simply become "associated". I'm sorry if I'm being unclear. | |
| Oct 22, 2015 at 16:34 | comment | added | march | I was going to use your code to test my solution against yours, but MixedRadix is new in V10.2, which I don't have, so I have another question. How does "summing a+b+g+h" result in {-1, 1}? That part is unclear. However: your finding of positions and such is unnecessary, because of you just Sort your list of 4-tuples, it will bring it automatically into the form you want. You can then Partition[ ..., 4] and sum over those rows. I can show this if you can clear up the part about the final summation. | |
| Oct 22, 2015 at 16:18 | history | edited | Enzo | CC BY-SA 3.0 | Corrected the definition of n |
| Oct 22, 2015 at 15:58 | history | edited | Enzo | CC BY-SA 3.0 | Added a possible solution |
| Oct 22, 2015 at 15:47 | comment | added | Enzo | @march that's correct, letters don't matter, that's why I chose j and k at the end. I'll edit the question with my solution. | |
| Oct 22, 2015 at 15:36 | history | edited | march | edited tags | |
| Oct 22, 2015 at 15:36 | comment | added | march | Post your solution! That way if we come up with different solutions, we can test speed against your solution (and we won't reproduce your solution). Also: how is n chosen? Is it related to the length of some list? Or is it a parameter in your problem? | |
| Oct 22, 2015 at 15:10 | history | asked | Enzo | CC BY-SA 3.0 |