in reply to Non-Formula based Text Encoding - with Compression

Aside from my failure to understand what value the output of this code offers, the quality of the code is very poor.

  1. use POD instead of single line comments for blocks of comments
  2. use strict and warnings (and declare your variables!)
  3. use Getopt::Long to allow your client to specify arguments you have instead hard coded or just use STDOUT
  4. don't use 3 arrays when 1 will suffice
  5. consider your solution is O(N^3) and that can be improved
  6. in fact ... there might be a mathematical formula that can derive these combinations in O(N) instead

In other words, something more like this:

#!/usr/bin/env perl use strict; use warnings; my @base = ( 'a'..'z', 'A'..'Z', 0..9 ); for my $i (@base) { print "$i\n"; for my $j (@base) { print "$i$j\n"; for my $k (@base) { print "$i$j$k\n"; } } } __END__ =head1 NAME non-forumla-based-text-encoder-with-compression.pl =head1 DESCRIPTION =over 4 =item * Create 242,234 unique codes, 1-3 characters in length, from the characters {a-zA-Z0-9}. =item * 62 (1 char codes) + 3844 (2 char codes) + 238,328 (3 char codes) = 242,234 unique codes. =item * (Somewhat like MIMEbase64 encoding, but my encoding is non-formula based.) =item * ... =back =cut
And then the client can redirect STDOUT to their own file of choice.

Now then ... i'd really like to see if someone can get this down to O(N). :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.