Skip to main content
deleted 1 character in body
Source Link
elcaro
  • 321
  • 1
  • 4

Perl 6, 117 bytes

say $_ <2??1!!permutations(+[(my@n=(^$_)my@n=^$_ .join.comb)]).elems÷[*] ([*] 2..$_ for @n.classify(&unique).values)for lines

and in a more readable fasion

for (lines) -> $number {
    say 1 and next if $number < 2;
    my @digits = (^$number).join.comb;
    my @duplicates = @digits.classify(&unique).values;
    my $unique_permutations = permutations(+@digits).elems ÷ [*] ([*] 2..$_ for @duplicates);
    say $unique_permutations;
}

Perl 6, 117 bytes

say $_ <2??1!!permutations(+[(my@n=(^$_).join.comb)]).elems÷[*] ([*] 2..$_ for @n.classify(&unique).values)for lines

and in a more readable fasion

for (lines) -> $number {
    say 1 and next if $number < 2;
    my @digits = (^$number).join.comb;
    my @duplicates = @digits.classify(&unique).values;
    my $unique_permutations = permutations(+@digits).elems ÷ [*] ([*] 2..$_ for @duplicates);
    say $unique_permutations;
}

Perl 6, 117 bytes

say $_ <2??1!!permutations(+[(my@n=^$_ .join.comb)]).elems÷[*] ([*] 2..$_ for @n.classify(&unique).values)for lines

and in a more readable fasion

for (lines) -> $number {
    say 1 and next if $number < 2;
    my @digits = (^$number).join.comb;
    my @duplicates = @digits.classify(&unique).values;
    my $unique_permutations = permutations(+@digits).elems ÷ [*] ([*] 2..$_ for @duplicates);
    say $unique_permutations;
}
Source Link
elcaro
  • 321
  • 1
  • 4

Perl 6, 117 bytes

say $_ <2??1!!permutations(+[(my@n=(^$_).join.comb)]).elems÷[*] ([*] 2..$_ for @n.classify(&unique).values)for lines

and in a more readable fasion

for (lines) -> $number {
    say 1 and next if $number < 2;
    my @digits = (^$number).join.comb;
    my @duplicates = @digits.classify(&unique).values;
    my $unique_permutations = permutations(+@digits).elems ÷ [*] ([*] 2..$_ for @duplicates);
    say $unique_permutations;
}