Discover the Answer

Solve the IBM Ponder This Challenge for November 2016 and discover the answer to the ultimate question of life, the universe, and everything!

The Challenge

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.

The Rules

function Team(breakfastShiftSize, lunchShiftSize, dinnerShiftSize) {
  this.a = parseInt(breakfastShiftSize);
  this.b = parseInt(lunchShiftSize);
  this.c = parseInt(dinnerShiftSize);
  if (this.a === this.b || this.b === this.a || this.a === this.c) {
    throw new Error('shift sizes cannot be equal');
  }
  Object.freeze(this);
}
Team.prototype = {
  toString: function() {
    return '(' + this.a + ', ' + this.b + ', ' + this.c + ')';
  },
  playGame: function(other, x) {
    return this[x] > other[x] ? 1 : this[x] < other[x] ? -1 : 0;
  },
  playSet: function (other) {
    var score = 0;
    score += this.playGame(other, 'a');
    score += this.playGame(other, 'b');
    score += this.playGame(other, 'c');
    return score > 0 ? 1 : score < 0 ? -1 : 0;
  },
  playMatch: function(other) {
    var score = 0;
    score += this.playSet(new Team(other.a, other.b, other.c));
    score += this.playSet(new Team(other.a, other.c, other.b));
    score += this.playSet(new Team(other.b, other.a, other.c));
    score += this.playSet(new Team(other.b, other.c, other.a));
    score += this.playSet(new Team(other.c, other.a, other.b));
    score += this.playSet(new Team(other.c, other.b, other.a));
    return score > 0 ? '>' : score < 0 ? '<' : '=';
  }
}
function compete(teams) {
  var i, j, team1, team2,
    winLossRecord, standings = [];
  for (i = 0; i < teams.length; i++) {
    winLossRecord = [];
    team1 = teams[i];
    for (j = 0; j < teams.length; j++) {
      team2 = teams[j];
      winLossRecord.push(team1.playMatch(team2));
    }
    standings.push(winLossRecord);
  }
  return standings;
}

Arrange Shifts (editable)



Headcount Target (editable)



Sous Chefs per Chef

(goal is to minimize)

Number of Chefs

Teams



Standings