Hi all

My friend gave me a riddle (very well known) in which I had to break a 40kg block in 4 pieces ( of integral weight) such that using all those pieces one can measure all weights in range 1 - 40 on a physical balance thingy (I hope that's what its called).

Then we decided to make a python program for it, but we cant find any algorithm to arrange 4 weights (i, j, k, l) and a weight w in equation.

We might be able to do it using regular expressions and built in eval() ... (we just started with the idea but, i feel very confident about it) but that feels like cheating ... or more like a walkthrough ...

It'll be great if someone could point me to the right direction by telling me what kind of algo do stuff like this (not too complex maths please :P)

Thanks in Advance

___________________