increment an array subset based on another subset [message #82417] |
Tue, 11 December 2012 16:39 |
havok2063
Messages: 24 Registered: December 2012
|
Junior Member |
|
|
I have a sorted list of ids and subsets they belong to:
ids = [11, 21, 45, 50, 56, 416, 430]
sub = [A, A, B, A, B, B, A]
I want to increment the ids of A based on the number of elements in subset B that lie in front of it. So for example , the 4th element will get incremented by 1 (50+1) since 1 element of B is in front. The last element will get incremented by 3 (430+3) since 3 elements of B lie in front of it. The first 2 elements of A don't get incremented.
I feel like the answer lies somewhere with where, total, or histogram, but the solution escapes me. Anyone have ideas?
Thanks.
|
|
|