Skip to content

Instantly share code, notes, and snippets.

@bertolo1988
Created June 21, 2016 16:49
Show Gist options
  • Save bertolo1988/8a7e8f3aef10115b4ca0b0557f1fa080 to your computer and use it in GitHub Desktop.
Save bertolo1988/8a7e8f3aef10115b4ca0b0557f1fa080 to your computer and use it in GitHub Desktop.
var n = parseInt(readline());
var s, skillsInput = readline().split(' ');
var skills = [];
var programmers = [];
var mathematicians = [];
var athletes = [];
var groups = [];
for (var i = 0; i < skillsInput.length; i++) {
var skillCursor = parseInt(skillsInput[i]);
switch (skillCursor) {
case 1:
programmers.push(i + 1);
break;
case 2:
mathematicians.push(i + 1);
break;
case 3:
athletes.push(i + 1);
break;
default:
athletes.push(i + 1);
break;
}
}
for (var j = 0; j < programmers.length && j < mathematicians.length && j < athletes.length; j++) {
groups.push({ programmer: programmers[j], mathematician: mathematicians[j], athlete: athletes[j] });
}
print(groups.length);
for (i = 0; i < groups.length; i++) {
print(groups[i].programmer + " " + groups[i].mathematician + " " + groups[i].athlete);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment