Skip to content

Instantly share code, notes, and snippets.

@omas
Created January 5, 2015 06:42
Show Gist options
  • Save omas/39654ef2f7ecdf525236 to your computer and use it in GitHub Desktop.
Save omas/39654ef2f7ecdf525236 to your computer and use it in GitHub Desktop.
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
var lines = chunk.split('\n');
var len = parseInt(lines.shift(),10);
var result = (function(words) {
return words.map(function(word) {
return word.split('').reverse().join('');
})
.sort()
.map(function(word) {
return word.split('').reverse().join('');
})
.join('\n');
}(lines.slice(0,len)));
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment