CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 06:13:30 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=3f9df4f86012c9b2a5dcef0188a63071bd5935056d4c9bb747ab71824b50b4efa%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22yq8EgUZ7g2ih95pdQEw-hUBm1Jmhcm5c%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cc363c7c69d817-BLR
AoC 2024, day 19 (Perl) - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use feature qw(say state);
- use List::Util qw(sum);
- $| = 1;
- # Read sections:
- $/ = '';
- my @section = map {[split /\n/]} <>;
- my @patt = split( /, /, $section[0][0] );
- # Part 1
- my $patt_re = '^(' . join('|', @patt) . ')*$';
- my @good = grep { m#$patt_re# } $section[1]->@*;
- say "Part 1: ", scalar @good;
- # Part 2
- sub recurse_count {
- my ($str) = @_;
- state %memo;
- return ($memo{$str}) if (exists $memo{$str});
- return ($memo{$str} = 1) if ($str eq '');
- my $ret = 0;
- foreach my $patt (@patt) {
- my $new_str = $str;
- $ret += &recurse_count( $new_str ) if ($new_str =~ s#^$patt##);
- }
- return ($memo{$str} = $ret);
- }
- say "Part 2: ", sum map {&recurse_count( $_ )} @good;
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 8 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 17 sec ago | 0.24 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 30 sec ago | 0.24 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 43 sec ago | 0.24 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 52 sec ago | 0.24 KB
-
⭐ Free Crypto Method ✅ NEVER SEEN BEFORE ⭐⭐⭐
JavaScript | 1 min ago | 0.24 KB
-
✅⭐ Make huge profits on trading ✅ NEVER SEEN...
JavaScript | 1 min ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 1 min ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand