You are given three piles of casino chips: white, green and black chips in the form of an array. Each day you need exactly two chips of different colors to play at the casino. You can chose any color, but you are not allowed to use two chips of the same color in a single day.
You will be given an array representing the number of chips of each color and your task is to return the maximum number of days you can play.
solve([1,1,1]) = 1, because after you pick on day one, there will be only one chip left
solve([1,2,1] = 2, you can pick twice; you pick two chips on day one then on day two
solve([4,1,1]) = 2
Brute force is not the way to go here. Look for a simplifying mathematical approach.
Want to propose a challenge idea for a future post? Email firstname.lastname@example.org with your suggestions!