CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 07:20:50 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=e1cd7b93da10a96321a00c1efeed67a7823cc52d0e0c2b61e5197ae7fe1d3d55a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%223saJCLgtYJCX3rZfAy-td7fBPRf9M_vC%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cc98e41c1d75e9-BLR
AoC 2024, day 8 (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);
- use Math::Vector::Real;
- use Algorithm::Combinatorics qw(combinations);
- my %Grid;
- my %Antennae;
- # Read in grid, make lists of antennae of same frequency
- while (<>) {
- chomp;
- my $x = 0;
- foreach my $chr (split //) {
- $Grid{ V($.,++$x) } = $chr;
- push( $Antennae{$chr}->@*, V($.,$x) ) if ($chr ne '.');
- }
- }
- # Takes a list of harmonics from an antenna to count
- sub countAntinodes {
- my %Antinodes;
- foreach my $list (values %Antennae) {
- foreach my $pair (combinations( $list, 2 )) {
- my $delta = $pair->[0] - $pair->[1];
- foreach my $node (map { $pair->[0] + $_ * $delta } @_) {
- $Antinodes{$node}++ if (exists $Grid{$node});
- }
- }
- }
- return (scalar keys %Antinodes);
- }
- say "Part 1: ", &countAntinodes(1, -2);
- say "Part 2: ", &countAntinodes(-$. .. $.);
Advertisement
Add Comment
Please, Sign In to add comment
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 9 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ X
JavaScript | 11 sec ago | 0.24 KB
-
⭐✅ Swapzone Glitch ✅ Working⭐⭐⭐ P
JavaScript | 23 sec ago | 0.24 KB
-
⭐⭐⭐ G2A Payment Exploit ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 31 sec ago | 0.24 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ N
JavaScript | 34 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 42 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ 7
JavaScript | 46 sec ago | 0.24 KB
-
⭐ ✅ Free Products Method ✅ ✅ NEVER SEEN BEFOR...
JavaScript | 51 sec 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