Skip to content

Instantly share code, notes, and snippets.

@omas
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save omas/61d67b5f5a4a0b82bab1 to your computer and use it in GitHub Desktop.

Select an option

Save omas/61d67b5f5a4a0b82bab1 to your computer and use it in GitHub Desktop.
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
var answers = {'1':0,'2':0,'3':0,'4':0};
var lines = chunk.toString().split('\n');
var len = parseInt(lines.shift(),10);
lines.toString().trim().split('').slice(0,len)
.forEach(function(v){
answers[v]++;
});
var result = (function(o){
var max = 0;
var min = len;
for (var key in o) {
min = Math.min(o[key],min);
max = Math.max(o[key],max);
}
return [max,min];
}(answers));
console.log(result.join(" "));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment