Help with computing differences in time values

newVBcoder124

New member
Joined
Mar 23, 2020
Messages
7
I am 61 years old and need some help with creating an algorithm.

Lets say I have a list of time values in SECONDS: (the list keeps growing)

146
391
475
597
253

What I want to do is compute how much FASTER or SLOWER (by percentage) the LAST value on the list is from the rest.

Example:

146
+ 391
+ 475
+ 597

= 1609

1609 / 4 = 402.25

402.25 - 253 (last value) = 149.25

Now is this correct?

149.25 / 402.25 = ~37.1%

Or this:

149.25 / 253 = ~59%

Or is the totally wrong way to do this. I want to know if the last value is FASTER or SLOWER than average.
Would the percentages be signed (+ / -)?

Thank you for your help
 
Let's see if I've got this straight.

You have 5 numbers and you want to express the last one as a percentage increase/decrease of the average of the 4 numbers above it.

In your case, the 5th number is 253. The average of the 4 above is 402.25. So the 5th number is 149.25 less than that average of 402.25.

That represents a decrease of 149.25/402.25 = 37.1% (approx)

Are you using excel? Is that the type of formula you are after?
 
You understood perfectly. I am trying to create an algorithm for computing the best completion time of a game I am programming using Visual Basic.
After posting this, I decided to obtain the fastest time from my list (that constantly grows) and do exactly what you just did TIME FOR TIME.
Thus:

If the last completed time was 253, and the best completed time was 146 then:

146 - 253 = -107

Abs(-107 / 253) = ~42% FASTER than the fastest time recorded.
IS THIS THE CORRECT WAY TO DO THIS?
 
No you should have 107/146 = 73.2% SLOWER
ie 253 is 73.2% slower than 146
Whatever you are comparing the difference to, has to go on the bottom of the fraction.

Bigger numbers are slower not faster (I assume we're measuring in time units??)
 
Thank you Harry.

Just so I know I am doing my code correctly:

I have a variable named "FTime" = fastest time recorded in database (gets written to at the finish of each game)
I also have a variable named "LTime" = last time game was finished

Thus if I do this: (I read from a file to get these stored values)

Abs((FTime - LTime) / FTime) = X%

Now I have an "IF" statement to prompt the player:

If FTime = LTime Then
[this means this is the first entry in the database]
ElseIf FTime < LTime then
[prompt the player that they completed the game X% faster...
ElseIf FTime > LTime then
[prompt the player that they completed the game X% slower...

Correct?

I sincerely and greatly appreciate ALL of your help!!!
 
Yeah that should do it. But what if the FTime = LTime and it's not the first entry in the database. That is what if your FT was say 200 and that was on your 5th game. And then on your 12th game you got 200 again. Do you want to send a message that says you've matched your fastest time?
 
HELP Harry!

I know I marked this resolved but need some more help. Computations are not working!
 
Ok, I figured out how to determine if it was the first record in the database by sending the number of records to the subroutine that does the player prompting. Done - it works.

So i decided to "cheat" and force a game to finish quickly to see if my prompts worked. Again, on the first game it worked fine. The game took 30 seconds to finish. I knew that this was going to be the fastest so I played a normal game slowly next. It took 3:53 (233 seconds).
Thus, the math as I thought was correct was: Abs((FTime - LTime) / FTime) = X%

30 - 233 = -203 / 30 = -6.76 equates to over 676%! This can't be correct - can it?
Oh, Visual Basic has a command that automatically converts equations to "string" values with the % sign in the proper place (multiplying by 100).
 
You're comparing 233 with 30.

If you compared 60 with 30, that would be twice as slow (half as fast??). That is 100% slower. The language is confusing - mainly because
bigger number = slower
If you compared 240 with 30, that would be 210/30 =700% slower. So 676% is correct.

Perhaps you want to rethink how you word your response. Maybe "half as fast" is better than "100% slower".
 
Thanks EVER so much for grounding me! You SIR are FANTASTIC and deserve credit for "Best Answers"
Please be safe and stay well!
I wish you and your family great health and happiness!
 
No worries! But I'm not a Sir - consider Harry short for Harriet! Just sayin'. :ROFLMAO::ROFLMAO:

Good health to you and your family too. Stay safe!
 
Top