#!/usr/local/bin/perl

##               PA  MN  NM  NH  IA  WI  OH  FL  NV  CO
my @state_evs = (21, 10,  5,  4,  7, 10, 20, 27,  5,  9);

my $number_states = $#state_evs + 1;
my $possibilities = (1 << $number_states);

my @state_space = ();
foreach my $state_index (0..($number_states-1)) {
   my $state_bit = 1 << $state_index;
   my $state_ev = $state_evs[$state_index];
   foreach (0..($possibilities-1)) {
      $state_space[$_] += $state_ev if $_ & $state_bit;
   }
}

my @state_space_sorted = sort {$a <=> $b} @state_space;
foreach (@state_space_sorted) {
   print $_, "\n";
}