solution to partition (list)