Here's solutions for 2,4,6,8,10 and proves? none for 3,5,7

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11141490 use warnings; use ntheory qw( forperm ); use List::AllUtils qw( none ); for my $n ( 2 .. 8, 10 ) { my @cols; forperm { my $c = join '', map +('-', 'a'..'z', 'A' .. 'Z')[$_], @_; push @{ $cols[ index $c, '-' ] }, $c } $n; my $start = $cols[0][0]; eval { find( "$start\n", @cols[1 .. $#cols ] ) }; } sub transpose { (local $_, my $new) = (shift, ''); $new .= "\n" while s/^./ $new .= $&; ''/gem; return $new; } sub find { my ($have, @next) = @_; my $flip = transpose($have); @next or $have eq $flip and warn( "$have\n"), die; my $pat = (split /\n/, $flip)[index $flip, "\n"]; my @haves = split /\n/, $have; my $trys = shift @next; for my $try ( grep /^$pat/, @$trys ) { none { ("$try" ^ "$_") =~ tr/\0// } @haves, and find( "$have$try\n", @next ); } }

Outputs:

-a a- -abc a-cb bc-a cba- -abcde a-cdeb bc-ead cde-ba deab-c ebdac- -abcdefg a-cbedgf bc-afgde cba-gfed defg-abc edgfa-cb fgdebc-a gfedcba- -abcdefghi a-cbedgfih bc-afghide cba-ghidef defg-iahbc edghi-bcfa fghiab-ecd gfidhce-ab hidebfca-g ihefcadbg- real 0m8.080s user 0m7.986s sys 0m0.090s

I think you are dealing with factorials, so good luck with 50 factorial!!

On the other hand, I could be wrong...


In reply to Re: Graph labeling problem by tybalt89
in thread Graph labeling problem by baxy77bax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.