new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
26
Task/Ordered-words/JavaScript/ordered-words-2.js
Normal file
26
Task/Ordered-words/JavaScript/ordered-words-2.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
var http = require('http');
|
||||
|
||||
http.get({
|
||||
host: 'www.puzzlers.org',
|
||||
path: '/pub/wordlists/unixdict.txt'
|
||||
}, function(res) {
|
||||
var data = '';
|
||||
res.on('data', function(chunk) {
|
||||
data += chunk;
|
||||
});
|
||||
res.on('end', function() {
|
||||
var words = data.split('\n');
|
||||
var max = 0;
|
||||
var ordered = [];
|
||||
words.forEach(function(word) {
|
||||
if (word.split('').sort().join('') != word) return;
|
||||
if (word.length == max) {
|
||||
ordered.push(word);
|
||||
} else if (word.length > max) {
|
||||
ordered = [word];
|
||||
max = word.length;
|
||||
}
|
||||
});
|
||||
console.log(ordered.join(', '));
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue