Thoughts on Parallelization

One of these days, as I was revisiting my early high school memories from notebooks, books, love-letters etc, I stumbled upon this simple but also tricky problem:

“One pump can fill up a tank with petrol in 25 minutes.

 Another tank can fill up the same tank with petrol in 15 minutes.

 If we combine both pumps together, how much time is needed for the tank to be filled?”

You can try solving it on your own, before scrolling to the answer. Don’t spoil it so quickly!

Probably you are bored though and you have better things to do, so you are already searching for the answer. Fair enough. If you think your life doesn’t have to deal with pumps, make your imagination work and consider the problem talking about employees and tasks. Or robots that make cars. Or … warriors killing zombies.

Or you just want to know what the answer is, now that you know the question.

OK, as a good friend who knows the movie, I’ll just post here the result as a hint, before you read the full answer. By having the correct result, you can try to explore the magic behind the numbers and find the answer on your own.

I shall now write that the answer is approximately 9 minutes and 23 seconds. (22.74 secs)

Now a simple step-by-step tutorial on how to get to the answer and avoid common pitfalls. We need to borrow or invent a measure that can make the comparison between the two pumps easier.

For me, the simplest way to achieve this, is to simply represent each pump’s efficiency rating that way:

Let P(t) be defined as:

    \[ P(t) = \frac{1}{t}, \]

where t is the time, preferably in seconds. The reason we use seconds instead of minutes is to avoid errors due to conversions.

If you know what you are doing, converting from decimal to seconds (1 minute consists of 60 and not 100 seconds) it is actually really easy. However, many people tend to forget the last step and some of them aren’t even aware of it, so use seconds, which after all is an SI unit.

Having all these in mind, we may proceed by finding the frequency for the two pumps separately, after we have converted minutes into seconds. So, 25 minutes is 1500 seconds and 15 minutes is 900 seconds. (Multiplying the minutes by 60)

    \[ P(1500) = \frac{1}{1500} = 6.66\cdot10^{-4} Hz, \]

    \[ P(900) = \frac{1}{900} = 11.11\cdot10^{-4} Hz, \]

    \[ P(900+1500) = \frac{1}{1500} + \frac{1}{900} = \]

    \[ =6.66\cdot10^{-4} + 11.11\cdot10^{-4} = \]

    \[ =17.77\cdot10^{-4} Hz \]

OK, we’ve done all that, and now we found the frequencyefficiencypowersay-it-however-you-want-it of the super-combined-pump. The only thing to do to convert our findings into reasonable results that answer the initial question is to FLIP them.

And maybe facelift them a bit.

Like that:

    \[ Time = \frac{1}{P} = \frac{1}{17.77\cdot10^{-4}} = 562.74 seconds \]

Taking into account that every minute consists of 60 seconds and dividing using Euclidean division, we have:

    \[ Minutes = \frac{562.74}{60} = 9 \]

    \[ Seconds: 562.74 &\equiv 22.74\mod60 \\ \]

So, as everyone can see, total time will be 9 minutes and 22.74 seconds.

But perhaps we can improve and formalize the procedure of getting there. I am a software developer and I find the solution a little bit “hard-coded“, so I’ll try to develop a more formal solution to the problem.

Let’s start the abstractions.

First step: “Ratio-Normalization” or

“The power of a pump can be measured by the time a certain pump does to fill the tank divided by one.”

Which can be simply expressed as:

    \[ P(t) = \frac{1}{t} \]

Extending this for 2 pumps:

    \[ P(t_1,t_2) = \frac{1}{t_1} + \frac{1}{t_2} \]

It is really easy now to extend it for n pumps:

    \[ P(t_1, t_2, ... , t_n) = \frac{1}{t_1} + \frac{1}{t_2} + ... + \frac{1}{t_n} \]


    \[n \in N \]

Or, more formally:

    \[ P(t_1, t_2, ... , t_n) = \sum_{i=1}^{N}\frac{1}{t_i} \]

The final step in order to get the result in time and not frequency is the following:

    \[ T(t_1, t_2, ... , t_n) = \frac{1}{\sum_{i=1}^{N}\frac{1}{t_i}}, \]

    \[ \forall n \in N \]

    \[ \forall t \in R^{+} \]

Also now known as Sören – Dominic function because it was written on  the train from Edinburgh to London King’s Cross,and he was the one with the fancy name on the train.


Memories from Monday 17/12/2012

So, that’s all for now, but I will probably explore more possibilities and usages and I will make another blog post when I will have the time to do so.


One thought on “Thoughts on Parallelization”

  1. Hello Alex,

    I just did 1/t1 + 1/t2 = 1/x. When I plug in the numbers 1/25 + 1/15 = 1/x and solve for x, I get exactly 9.375 minutes or 9 minutes 22.5 seconds. I think your going through the Hz approximations and the reciprocals of 1500 and 900 seconds threw your answer a little off. =_)


Leave a Reply