--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.16;
+
+my ($c, @s);
+
+while (<>) {
+ $c++;
+ chomp;
+ my $i = 0;
+ for my $b (split//) {
+ $s[$i++] += $b;
+ }
+}
+
+my ($e, $g);
+for my $b (@s) {
+ $e .= ($b > $c/2) ? '1' : '0';
+ $g .= ($b > $c/2) ? '0' : '1';
+}
+
+say oct("0b$e")*oct("0b$g");
+
--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.16;
+
+my ($c, @s);
+
+chomp (my @nums = <>);
+$c = @nums;
+
+my @n = @nums;
+my $pos = 0;
+while (@n > 1) {
+ my $ones = grep { substr ($_, $pos, 1) eq '1' } @n;
+ if ($ones >= @n/2) {
+ @n = grep { substr ($_, $pos, 1) eq '1' } @n;
+ } else {
+ @n = grep { substr ($_, $pos, 1) eq '0' } @n;
+ }
+ $pos++;
+}
+my $ox = oct "0b".$n[0];
+
+@n = @nums;
+$pos = 0;
+while (@n > 1) {
+ my $ones = grep { substr ($_, $pos, 1) eq '0' } @n;
+ if ($ones > @n/2) {
+ @n = grep { substr ($_, $pos, 1) eq '1' } @n;
+ } else {
+ @n = grep { substr ($_, $pos, 1) eq '0' } @n;
+ }
+ $pos++;
+}
+my $co = oct "0b".$n[0];
+
+say $ox * $co;
+