First commit of partial RosettaCode contents.
Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
commit
1e05ecd7ee
781 changed files with 9080 additions and 0 deletions
11
Task/Ordered_words/JavaScript/ordered_words.js
Normal file
11
Task/Ordered_words/JavaScript/ordered_words.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
var fs = require('fs'), print = require('sys').print;
|
||||
fs.readFile('./unixdict.txt', 'ascii', function (err, data) {
|
||||
var is_ordered = function(word){return word.split('').sort().join('') === word;},
|
||||
ordered_words = data.split('\n').filter(is_ordered).sort(function(a, b){return a.length - b.length}).reverse(),
|
||||
longest = [], curr = len = ordered_words[0].length, lcv = 0;
|
||||
while (curr === len){
|
||||
longest.push(ordered_words[lcv]);
|
||||
curr = ordered_words[++lcv].length;
|
||||
};
|
||||
print(longest.sort().join(', ') + '\n');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue