--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.38;
+
+my $sum;
+while (<>) {
+ my ($have, $win) = /: (.*) \| (.*)/;
+ my %is_win = map { $_ => 1 } ($win =~ /(\d+)/g);
+ my $count = grep { $is_win{$_} } ($have =~ /(\d+)/g);
+ $sum += 1 << ($count-1) if $count;
+}
+say $sum;
--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.38;
+
+my $sum;
+my @scores;
+while (<>) {
+ my ($have, $win) = /: (.*) \| (.*)/;
+ my %is_win = map { $_ => 1 } ($win =~ /(\d+)/g);
+ push @scores, scalar grep { $is_win{$_} } ($have =~ /(\d+)/g);
+}
+
+my @cards = (1) x @scores;
+while (@scores) {
+ my $n = shift @scores;
+ my $c = shift @cards;
+ $sum += $c;
+ next if !$n;
+ $cards[$_] += $c for 0 .. $n-1;
+}
+
+say $sum;