Permutations · Feb 28, 12:21 PM by Dylan Doxey
Last night was was thinking to myself, "Self, I sure would like a list of all the permutations of these characters in a string of size n."
That's the point when I set myself to work and produced this little snippet of code.
1 sub permute {
2 my ($letters_ra,$size) = @_;
3
4 return
5 if not $size;
6
7 my $words_ra = permute( $letters_ra, $size - 1 );
8
9 return $letters_ra
10 if not @{ $words_ra || [] };
11
12 my @words;
13
14 for my $word (@{ $words_ra }) {
15
16 for my $letter (@{ $letters_ra }) {
17
18 push @words, "$letter$word";
19 }
20 }
21
22 return \@words;
23 }
Yea, that gets the job done.
27 # create a list of a-z
28 my @letters = map { chr $_ } ( 97 .. 122 );
29
30 # create a list of all four letter words
31 my $words_ra = permute( \@letters, 4 );
Now that we've got this list laying around, let's see if we can register any of them as domains.
35 use LWP::Simple qw( get );
36
37 WORD:
38 for my $word (@{ $words_ra }) {
39
40 my $json = get( "http://instantdomainsearch.com/services/quick/?name=$word" );
41
42 my ($com,$net,$org) = $json =~ m{'name':'$word','com':'(\w+)','net':'(\w+)','org':'(\w+)'}xms;
43
44 next WORD
45 if "$com$net$org" eq 'uuu';
46
47 print "$word: com:$com, net:$net, org:$org\n";
48 }
That's going to be 264 domain lookups which average around 1 second per. That should take about 42 hours to run.
I've found that just because instantdomainsearch.com reports it as available, doesn't mean it's available.
Happy computing.

Commenting is closed for this article.
Booting From a Thumb-Drive? Just a Little Program... to be sure.
