-
-
Save zoffixznet/b569b3f4a337c3c554b22b3fbdc69e90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my %words is Set = lines; | |
sub make-LDWL(\word, @prev is copy = []) { | |
make-LDWL $_, take [|@prev, $_] for %words{word.comb.combinations(word.chars-1)».join}:k | |
} | |
my @longest; | |
for sort keys %words { | |
my $cur := ([$_], |gather make-LDWL $_).sort(-*).head; | |
say "One of longest chains for `$_` is $cur.join(' ▶ ')"; | |
@longest = $cur if $cur > @longest; | |
} | |
say @longest; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment