# Find how close each letter is to half of the total word possibilities to ensure maximum gain every guess after being sorted foreach my $occur (keys %alphabet) { $alphabet{$occur} = abs($#narrowed/2 - abs($alphabet{$occur} - $#narrowed + 1)); } say $_ foreach @narrowed; # Word list say $#narrowed + 1; say sort { $alphabet{$a} <=> $alphabet{$b} } keys %alphabet; # Sort ascendingly; whichever letter is closest to 0, i.e., and therefore whichever letter will eliminate the most words.