number partition algorithm