-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08.pl
55 lines (51 loc) · 1016 Bytes
/
08.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use feature 'say';
use Clipboard;
use List::Util qw/sum/;
use Math::Cartesian::Product;
use Math::Complex;
sub out {
my $out = shift;
Clipboard->copy_to_all_selections($out);
print "$out\n";
}
my $o;
my $o1;
my @LOOKUP = qw/x e x x g a b d c f/;
my @SSEG=qw/abcefg cf acdeg acdfg bcdf abdfg abdefg acf abcdefg abcdfg/;
my %RSEG;
{
my $i=0;
for my $s (@SSEG) {
$RSEG{$s} = $i++;
}
}
while (<>) {
chomp;
my @l = split(/ \| /);
my @a = split(' ', $l[0]);
my @od = split(' ', $l[1]);
my %four;
my %count;
for my $a (@a) {
my $is_four = (length($a) == 4);
for my $c (split('', $a)) {
$count{$c}++;
$four{$c}++ if $is_four;
}
}
my $v;
for my $x (@od) {
my $c;
$c = join('', sort {$a cmp $b} (map {
$LOOKUP[$count{$_} - 3 * !$four{$_}]
} split('', $x)));
$v.=$RSEG{$c};
$o1++ if ($RSEG{$c} =~ /[1478]/);
}
$o+=$v;
}
out $o1;
out $o;