--- /dev/null
+#!/usr/bin/perl
+
+use v5.30;
+use strict;
+
+my %neigh;
+while (<>) {
+ my ($src, $dst) = /(\d+)/g;
+ push @{ $neigh{$src} }, $dst;
+ push @{ $neigh{$dst} }, $src;
+}
+
+my %used;
+my $max;
+sub walk {
+ my ($score, @path) = @_;
+ my $now = $path[-1];
+ $max = $score if !$max || $max < $score;
+ say "$score: ", join(' ', @path);
+ for my $next (@{ $neigh{$now} }) {
+ next if $used{$now,$next} || $used{$next,$now};
+ $used{$now,$next} = 1;
+ walk ($score + $now + $next, @path, $next);
+ delete $used{$now,$next};
+ }
+}
+
+walk(0, 0);
+say $max;