new files

This commit is contained in:
Ingy döt Net 2013-04-10 12:38:42 -07:00
parent 3af7344581
commit 86c034bb8b
1364 changed files with 21352 additions and 0 deletions

View 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');
});

View 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(', '));
});
});