Andrea Desole said:
To me it just meant "for example all the heavier rocks are 1.1 kg heavier"
Let's say we do your technique, and we find the weight to be 1 + 2 + 3
+... +n + 0.6 kilograms heavier. So which pile contains the heavy rocks?
Well, if the heavy rocks are 1.1kg, and the non-heavy rocks are 1.0kg, then
the 6th pile contains the heavy rocks. But if the heavy rocks are 1.2kg, and
the non-heavy rocks are 1.0kg, then the 3rd pile contains the heavy rocks.
And if the heavy rocks are pi kilograms, and the non-heavy rocks are
square-root-of-two kilograms... which pile is it then?
Collapsing into black holes isn't so much a question of being infinitely
massive, but more one of being infinitely dense. For most intents and
purposes, there is "infinite" mass in the universe, and yet the universe
doesn't immediatel collapse into one giant black hole, because the mass is
distributed in such a way so as to make the universe mostly non-dense.
Similarly, perhaps each "pile" of rocks is arranged so that the rocks
within those piles are far away from each other (or of a large enough
volume, perhaps hollow inside) such that they would not collapse into a
black hole.
More probably, you don't ACTUALLY have an infinite number of rocks, but
rather, the "client" is stating that you have no upper bound on the number
of rocks you are allowed to use (e.g. if you need more rocks, the client is
willing to pay for more rocks to be acquired).
oh well, in that case you can come up with several questions:
- where are these infinite number of rocks coming from? There must be a
very big mine somewhere
This information probably won't help you solve the problem. The problem
statement says you "have" the rocks, implying that you have access to them,
so perhaps the client will create them on the fly as you ask for them.
- who can take the time to collect an infinite number of rocks?
The problem isn't bounded by time either, so if your algorithm takes a
billion years to complete, that's okay, it seems.
- who can take the time to weight them?
Perhaps the solution does not involve weighing every single rock;
perhaps you can weigh only 2n^2 rocks, where n is the number of piles. You
might protest "But how can the client guarantee that all the rocks weight
exactly 1.0 kilogram unless (s)he weighs them all?" Well, perhaps the client
*generates* the rocks for you, thus guaranteeing that every rock provided to
you will be 1.0 kilogram, except for the heavy ones.
- if the rocks are of the same material, and some are 10% heavier, they
will probably be 10% bigger. Can't you just spot them?
They might not be 10% bigger: they might be the same size, with the
non-heavy ones hollow in the center. I think the problem statement mentions
that the rocks are essentially indistinguishable except for that difference
in mass.
- Oliver