Summary
Videos which are sped up every time a particular word is said exist for everything from the Bee Movie to the classic Rick Roll. The goal for this challenge is to figure out how much you'd have to slow down the sped-up video in order to match the duration of the original video.
For example, the original Bee Movie has a duration of 95 minutes. The sped up version is 5:40 or ~5.667 minutes. 95/5.667 = 16.76. We'd have to play the sped up version 16.76x slower in order for the overall duration to match the original movie.
Inputs
Your program must take in 3 inputs:
- The duration of the original video (Bee Movie was 95 minutes)
- The speedup factor per occurence (Bee Movie was 15% or .15)
- A list of timestamps of occurrences (Bee movie has more than I care to look up/list)
The exact way these are passed in is flexible: 3 separate parameters is my default assumption, but if you want to take in a single list of values and pop the duration/speedup factor off the front that's fine, or take a single string in JSON or whatever format floats your boat, etc.
For the duration: seconds, minutes, or some builtin duration type are all fine.
For the speedup factor of the bee movie, any of 15, .15, or 1.15 could be used to represent the 15% speedup.
You can assume the occurrences are ordered in the most convenient manner, but there can be duplicate values (such as multiple characters talking over one another in a movie).
Output
A scaling factor to make the durations of the original and sped-up video match. The exact format is flexible.
Examples
{"duration": 10, "speedup-factor": 2, "occurrences": [1,2,3,4,5,6,7,8,9]} -> {"slowdown-factor": 5.004887585532747}
{"duration": 500, "speedup-factor": 1.15, "occurrences": [1,2,3, ..., 497, 498, 499]} -> {"slowdown-factor": 65.21739130434779}
{"duration": 100, "speedup-factor": 3, "occurrences": [0]} -> {"slowdown-factor": 3}
{"duration": 100, "speedup-factor": 3, "occurrences": [0, 0, 0]} -> {"slowdown-factor": 27}
{"duration": 100, "speedup-factor": 100, "occurrences": [99.99]} -> {"slowdown-factor": 1.0000990098}
Notes: First two generated programmatically with 100/(sum(1/(2**i) for i in range(10)))
and 500/(sum(1/(1.15**i) for i in range(500)))
. 4th example: 3 * 3 * 3 = 27x speedup, occurring right at the start of the video. Last example calculated by hand with 100/(99.99 + .01/100)
Note
I've kept most of the examples fairly simple, but I believe they cover all the relevant edge cases (a program which solves all of them should be totally correct). If I've left things ambiguous or difficult to parse, let me know and I'll add comments!
5.00488758553
. Maybe I'm misunderstanding something. It seems to be that sped up video is about 2 seconds, since the segments takes1,1/2,1/4,...
seconds each, requiring a slowdown factor of about 5 given the 10-second original. \$\endgroup\$original duration / sped-up duration
\$\endgroup\$