How to run a calculation on this array?
Hey all! Apologies in advance if this doesn’t make sense, but I have 0 skills and figuring out how to do this would help me out a lot. I am trying to either create a new array or edit this one with a time calculation. The thing that I’m specifically confused about is how to run a different calculation based on the letter in the 2nd column. Say this is the array:
01:22 K
0:39 K
0:39 C
0:00 U
The calculation would assign new times to each line based on the letter and how much the total time has reduced by. So the total shown above is 2 hours and 40 minutes, but say I wanted to reduce it by 1 hour (it will always be a reduction of time) so I want to generate a new array with a new breakdown that now totals 1 hour and 40 minutes. The tricky part is that the time is reduced differently depending on the letter. U gets reduced first, then C, then any remaining time is evenly divided by each K.
So the full 39 mins would be removed from the C, and then the remaining 21 minutes is divided by the 2 K lines. Obviously that doesn’t evenly divide, so 1 would reduce by 11 minutes and 1 would reduce by 10 minutes - it does not matter which one is reduced by which amount, so long as they are as even as possible. Must be whole numbers.
The new array would show 1:11 K, 29 K, 0 C, 0 U.
If U had a value though, say 21 for the sake of easy math, the U and C would become 0 and the Ks would remain as is. If U had a value of 1:00, just the U would become 0 and everything else would remain as is.
Hopefully that makes sense and thank you so much in advance for any insight you can provide. 😊