Learning to divide and conquer