Bob meets a magician with two bags and a chest on a bridge. The magician challenges him with the following enigma:
Here is a bag A, holding 5080 pebbles.
Here is another bag B.
Most of the pebbles are unique, or very little alike, regarding the following features: size, color, origin, weight, value. You may examine each pebble as much as you like, but you can't know the pebble's value by merely looking at it. Some pebbles are tremendously much more valuable than others.
You are allowed to pick as many pebbles as you want from bag A and put them into the bag B. You could do that as many times as you want, but each time I will weight the bag on a magic scale. This magic scale performs an unknown, deterministic computation for around 5 seconds, based on the cumulative value of the pebbles. Afterwards, it either answers "OK" or "No it's too much.", with regard to a secret threshold only known by the magic scale.
When it answers "No it's too much", you have to try again. You would do that by putting back as many pebbles as you like in the bag A. You're free the examine the bag and choose carefully which pebble you want to put back. If it answers "OK", you may choose to leave and earn as many gold coins as there are pebbles in the bag B.
The pebbles in the bags would be of no use to anyone because no one is able to estimate their value (except for the magic scale of course), whereas gold coins are the country's currency.
When the sun sets and finally reaches the same height as it currently occupies, I will, if you're still here, weight the bag B one last time. If the magic scale answers "OK", I will give you as many gold coins as there are pebbles in the bag B. Then, I will depart from here.
Hearing this, Bob doesn't take very long to understand how to proceed and leave with as many coins as possible.
Note: the magician is prone to pity and may wait just a little bit if you're late, yet close to getting an "OK" from the magic scale (but only a little bit).
Edit: Fix according to remark of @dr-xorile. Also both bags can be ordered.