--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.38;
+use experimental 'multidimensional', 'for_list', 'builtin';
+use builtin 'indexed';
+use List::Util;
+use Y::AoC::Task;
+$; = ';';
+# t;
+
+$/ = "\n\n";
+
+my $sum;
+MAP:
+while (<>) {
+ chomp;
+ my @map = map { [ split // ] } split /\n/, $_;
+
+ say "============ $#{ $map[0] } x $#map ==========";
+ COL:
+ for my $r1 (1 .. $#{ $map[0] }) {
+ say "Trying col $r1";
+ for my $x (0 .. $r1) {
+ my $x1 = 2*$r1-$x-1;
+ say "col $x vs $x1";
+ next if $x1 > $#{ $map[0] };
+ for my $y (0 .. $#map) {
+ next COL if $map[$y][$x] ne $map[$y][$x1];
+ }
+ }
+ say "X match at $r1";
+ $sum += $r1;
+ next MAP;
+ }
+ ROW:
+ for my $r1 (1 .. $#map) {
+ say "Trying row $r1";
+ for my $y (0 .. $r1) {
+ my $y1 = 2*$r1-$y-1;
+ say "row $y vs $y1";
+ next if $y1 > $#map;
+ for my $x (0 .. $#{ $map[0] }) {
+ next ROW if $map[$y][$x] ne $map[$y1][$x];
+ }
+ }
+ say "Y match at $r1";
+ $sum += 100*$r1;
+ next MAP;
+ }
+ die "No match at $.";
+}
+
+say $sum;
+
+
--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.38;
+use experimental 'multidimensional', 'for_list', 'builtin';
+use builtin 'indexed';
+use List::Util;
+use Y::AoC::Task;
+$; = ';';
+# t;
+
+$/ = "\n\n";
+
+my $sum;
+MAP:
+while (<>) {
+ chomp;
+ my @map = map { [ split // ] } split /\n/, $_;
+
+ my $n;
+ COL:
+ for my $r1 (1 .. $#{ $map[0] }) {
+ say "Trying col $r1";
+ for my $x (0 .. $r1) {
+ my $x1 = 2*$r1-$x-1;
+ say "col $x vs $x1";
+ next if $x1 > $#{ $map[0] };
+ for my $y (0 .. $#map) {
+ next COL if $map[$y][$x] ne $map[$y][$x1];
+ }
+ }
+ say "X match at $r1";
+ $n += $r1;
+ goto OUT;
+ }
+ ROW:
+ for my $r1 (1 .. $#map) {
+ say "Trying row $r1";
+ for my $y (0 .. $r1) {
+ my $y1 = 2*$r1-$y-1;
+ say "row $y vs $y1";
+ next if $y1 > $#map;
+ for my $x (0 .. $#{ $map[0] }) {
+ next ROW if $map[$y][$x] ne $map[$y1][$x];
+ }
+ }
+ say "Y match at $r1";
+ $n = 100*$r1;
+ goto OUT;
+ }
+ OUT:
+
+ for my $sx (0 .. $#{ $map[0] }) {
+ for my $sy (0 .. $#map) {
+ my $old = $map[$sy][$sx];
+ $map[$sy][$sx] = ($old eq '.') ? '#' : '.';
+ say "######################### $sx,$sy $old $map[$sy][$sx]";
+ say "============ $#{ $map[0] } x $#map ==========";
+ COL:
+ for my $r1 (1 .. $#{ $map[0] }) {
+ next if $n == $r1;
+ say "Trying col $r1";
+ for my $x (0 .. $r1) {
+ my $x1 = 2*$r1-$x-1;
+ say "col $x vs $x1";
+ next if $x1 > $#{ $map[0] };
+ for my $y (0 .. $#map) {
+ next COL if $map[$y][$x] ne $map[$y][$x1];
+ }
+ }
+ say "X match at $r1";
+ $sum += $r1;
+ next MAP;
+ }
+ ROW:
+ for my $r1 (1 .. $#map) {
+ next if $n == 100*$r1;
+ say "Trying row $r1";
+ for my $y (0 .. $r1) {
+ my $y1 = 2*$r1-$y-1;
+ say "row $y vs $y1";
+ next if $y1 > $#map;
+ for my $x (0 .. $#{ $map[0] }) {
+ next ROW if $map[$y][$x] ne $map[$y1][$x];
+ }
+ }
+ say "Y match at $r1";
+ $sum += 100*$r1;
+ next MAP;
+ }
+ $map[$sy][$sx] = $old;
+ }
+ }
+ die "No match at $.";
+}
+
+say $sum;
+
+