#!/usr/bin/perl -w

print "Reading word list file.\n";
open (FH, "../dicts/oizwyhsglpabcdef.txt");
  @dict = <FH>;
close (FH);

print "Lines read: ".($#dict + 1)."\nWords: ";

foreach $wd (@dict) {
  chomp ($wd);
  $t = $wd;
#           ABCDEF
#  $t =~ s/[abcdef]//g;          #   77 words
#           ABCDEF01
#  $t =~ s/[abcdefoi]//g;        #  264 words
#           ABCDEFO125
#  $t =~ s/[abcdefoizs]//g;      #  871 words
#           ABCDEFO1256
#  $t =~ s/[abcdefoizsg]//g;     # 1185 words
#           ABCDEFO124567
#  $t =~ s/[abcdefoizhsgl]//g;   # 3757 words
#           ABCDEFO124567
#  $t =~ s/[abcdefoizysgl]//g;   # 3597 words '4' as a 'y'
#          ABCDEFO12345679
   $t =~ s/[abcdefoizwhsglp]//g; # 6188 words 3-W 4-h 9-P
#           ABCDEF012345679
#  $t =~ s/[abcdefoizwysglp]//g; # 5829 words 3-W 4-y 9-P

  # Just using the numbers only and rotating them (ie,
  # as we would have done on a calculator
  #         0123456789
#  $t =~ s/[oizehslbg]//g; # 525 words
#  $t =~ s/[oiehsbg]//ig; # 189 words

  # use the letters as follows:
  #     a b c d e f O I Z h S G L
  #     a b c d e f 0 1 2 4 5 6 7
  # or...
  #     a b c d e f O I Z Y S G L
  # note that you can expand this if you like with
  # whatever you are happy with.
  # You could have a 3 as a 'W' (imagine it on its side)
  # and you could use a 9 as a 'P' (imagine a mirror image).
  if (length($t) == 0) {
    #this word contains letters that can be used as hex
    #find out how long it is and put it in a hash
    $n = length($wd);
    $wh{$n} .= " $wd"
  }
}
@kl = sort keys (%wh);
open (OP, ">hexwordlist.txt");
  foreach $n (@kl) {
    print "\n$n:\n";
    #we have the list of key lengths.
    @wds = split " ", $wh{$n};
    foreach $x (@wds) {
      print "$x ";
      print OP "$x\n"
    }
  }

close OP
