How would I answer this using PHP?
> You decided that you would give a shot at riding a unicycle while
> balancing weights on both your hands. To make sure that you don't
> fall, you want the weights in your hands to balance out as much as
> possible (i.e. the difference between the sum of the weights in either
> of your hands must be as small as possible). Given the weights you
> have, determine the smallest difference in weight between your left
> and right hands.
> 
> Sample Input: 1 10 6
> 
> Sample Output: 3

Also, you don't have to use all the weights, but you can't use 0 weights. I'm thinking that a recursive function would be the best way to solve this.

By the way, this isn't my homework or anything, it's a question on a past Dwite contest.
How would I answer this using PHP?
===

> You decided that you would give a shot at riding a unicycle while
> balancing weights on both your hands. To make sure that you don't
> fall, you want the weights in your hands to balance out as much as
> possible (i.e. the difference between the sum of the weights in either
> of your hands must be as small as possible). Given the weights you
> have, determine the smallest difference in weight between your left
> and right hands.
> 
> Sample Input: 1 10 6
> 
> Sample Output: 3

Also, you don't have to use all the weights, but you can't use 0 weights. I'm thinking that a recursive function would be the best way to solve this.

By the way, this isn't my homework or anything, it's a question on a past Dwite contest.