12 chefs (one for each month of the year) each has N sous chefs. The chefs divide the sous chefs into three shifts: N1, N2 and N3 where N=N1+N2+N3 and no two numbers are the same. After this partition, the three sets of sous chefs are randomly assigned to prepare the three daily meals (morning, lunch, and dinner). For each meal, the chef who has more sous-chefs wins. If both chefs chose the same number - the result is a draw. When comparing two chefs, the one who won more meals wins.
For example: if N=9 and January's chef decided to split to 1,2,6 and February's chef decided to split to 2,3,4 then there are six possible permutations:
Jan Feb meals winner overall winner
1 2 6 vs 2 3 4 Feb, Feb, Jan Feb
1 6 2 vs 2 3 4 Feb, Jan, Feb Feb
2 1 6 vs 2 3 4 Draw, Feb, Jan Draw
2 6 1 vs 2 3 4 Draw, Jan, Feb Draw
6 1 2 vs 2 3 4 Jan, Feb, Feb Feb
6 2 1 vs 2 3 4 Jan, Feb, Feb Feb
So the end result is that February wins. On the other hand, if the March chef chose 0,4,5, then he will win against February, but will lose to January.
IBM's Chef Watson analyzed the situation as a restaurant critic, and found that in every duel, the chef who wins is the one whose month appears first after a random date, i.e., when the June and July chefs are competing, June will win, but April will lose to December. In the event of a tie (like April and October), the culinary match ends with a tie as well.
Find the minimal N and a possible choice of the 12 chefs that can allow such a situation to occur. Supply your answer as a set of 12 triplets of integers.
function getTeams(teamCount, teamSize) {
var i, a, b, c,
n = parseInt(teamCount), // number of chefs
m = parseInt(teamSize), // number of sous chefs
teams = [];
for (i = 0; i <= n/2 - 1; i++) {
c = n/2 + i; /* J.P.S. */
b = 1 + n/2 + i; /* J.P.S. */
a = m - (b + c);
teams.unshift(new Team(a, b, c));
}
for (i = n/2; i <= n - 1; i++) {
c = i - (n/2); /* J.P.S. */
b = 1 + n + i - n/2; /* J.P.S. */
a = m - (b + c);
teams.unshift(new Team(a, b, c));
}
return teams;
}
function getTeams(teamCount, teamSize) {
var i, a, b, c,
n = parseInt(teamCount), // number of chefs
m = parseInt(teamSize), // number of sous chefs
teams = [];
for (i = 0; i <= n/2 - 1; i++) {
c = 0; /* to do */
b = 1; /* to do */
a = m - (b + c);
teams.unshift(new Team(a, b, c));
}
for (i = n/2; i <= n - 1; i++) {
c = 0; /* to do */
b = 1; /* to do */
a = m - (b + c);
teams.unshift(new Team(a, b, c));
}
return teams;
}
Headcount Target (editable)
function getMinTeamSize(teamCount) {
var n = parseInt(teamCount);
return 3*n + n/2; /* J.P.S. */
}
function getMinTeamSize(teamCount) {
var n = parseInt(teamCount);
return 3; /* to do */
}