I promise this is not a homework problem, but my brain cannot figure out the math to solve this problem that is relatable to a similar situation to my own:
You want to run on a treadmill at an average of 6.4 mph for 29 minutes. However, the treadmill can only go at an integer number of miles per hour, so you can set it to go at 5, 6, 7, etc. but not 6.4. You do not want to go any faster than 8 mph, and no slower than 4 mph. How do you divide the 29 minutes into time blocks, where each block is at a certain integer mph, such that by averaging each block you get 6.4 mph?
I am sure there are a lot of possible ways to solve this, and by no means the solution is unique:
My way by assuming that we're allowed to switch the speed at intervals we choose.
We want to have something like $$ \frac{(x_1k_1+\ldots +x_nk_n)}{x}=6.4 $$ with $k_i\in\{4,5,6,7,8\}$ and $\sum x_i=x$. Clearly we want to have an integer at the RHS, so let's choose $x=10$ for now which gives us $$ \frac{(x_1k_1+\ldots +x_nk_n)}{10}=6.4\iff (x_1k_1+\ldots +x_nk_n)=64 $$ this means, since we chose to partition $29$ minutes into $10$ parts, that we change the speed every $174$ seconds (we change it 10 times including the starting velocity). Now we just need to find a combination such that $$ (x_1k_1+\ldots +x_nk_n)=64 $$
holds, which works for $x_1=8,k_1=6$ and $x_2=2,k_2=8$. After all this means, that we start with $6$mph and stay $8*174=1392$ seconds at this speed and then change it instantly to $8$ mph and stay like this for the remaining $2*174=348$ seconds which will give us an average speed of $6.4$mph.