algorithmic solution in python to an interesting brain teaser regarding weights on a scale