Find All Possible Unique Combinations of Letters in a WordCompute the multinomial coefficientFinding the most...

Are there any individual aliens that have gained superpowers in the Marvel universe?

Is there a term for the belief that "if it's legal, it's moral"?

I found a password with hashcat, but it doesn't work

Is declining an undergraduate award which causes me discomfort appropriate?

Justifying Affordable Bespoke Spaceships

Find All Possible Unique Combinations of Letters in a Word

Print one file per line using echo

Find the common ancestor between two nodes of a tree

How do internally carried IR missiles acquire a lock?

What does it cost to buy a tavern?

Draw a symmetric alien head

Counterfeit checks were created for my account. How does this type of fraud work?

How can I prevent a user from copying files on another hard drive?

Prisoner on alien planet escapes by making up a story about ghost companions and wins the war

Is "Busen" just the area between the breasts?

Extending prime numbers digit by digit while retaining primality

Warnings using NDSolve on wave PDE. "Using maximum number of grid points" , "Warning: scaled local spatial error estimate"

Can I enter the UK for 24 hours from a Schengen area, holding an Indian passport?

Improve appearance of the table in Latex

Drawing a second weapon as part of an attack?

Why does std::string_view create a dangling view in a ternary expression?

How do I professionally let my manager know I'll quit over an issue?

What mathematical theory is required for high frequency trading?

Can you use one creature for both convoke and delve for Hogaak?



Find All Possible Unique Combinations of Letters in a Word


Compute the multinomial coefficientFinding the most 'unique' wordShortest code to determine if a string is a palindromeSame word when missing lettersRemove letters while keeping strings uniqueOn the Subject of PasswordsFind the shortest pangrams from a word listWord stays a word after taking away a letter. RepeatFind unique elements based on a given keyHow many moves?Find what a phrase with removed letters originally said in fewest characters






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2












$begingroup$


You are given a string, which will contain ordinary a-z characters. (You can assume this will always be the case in any test, and assume that all letters will be lowercase as well). You must determine how many unique combinations can be made of the individual characters in the string, and print that number. However, duplicate letters can be ignored in counting the possible combinations. In other words, if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total.



Shortest byte count wins, looking forward to seeing some creative solutions in non-golfing languages!










share|improve this question











$endgroup$












  • $begingroup$
    However, duplicate letters cannot be ignored in counting the possible combinations - if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total. These contradict each other
    $endgroup$
    – Benjamin Urquhart
    9 hours ago










  • $begingroup$
    @BenjaminUrquhart Corrected. I apparently had some mental double-negative thing going on. ;)
    $endgroup$
    – I_P_Edwards
    9 hours ago






  • 1




    $begingroup$
    Strongly related, possible dupe
    $endgroup$
    – Giuseppe
    9 hours ago






  • 3




    $begingroup$
    @Giuseppe I don't think this is a dupe of that; the specifics of this question allow for much shorter implementations
    $endgroup$
    – ArBo
    8 hours ago


















2












$begingroup$


You are given a string, which will contain ordinary a-z characters. (You can assume this will always be the case in any test, and assume that all letters will be lowercase as well). You must determine how many unique combinations can be made of the individual characters in the string, and print that number. However, duplicate letters can be ignored in counting the possible combinations. In other words, if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total.



Shortest byte count wins, looking forward to seeing some creative solutions in non-golfing languages!










share|improve this question











$endgroup$












  • $begingroup$
    However, duplicate letters cannot be ignored in counting the possible combinations - if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total. These contradict each other
    $endgroup$
    – Benjamin Urquhart
    9 hours ago










  • $begingroup$
    @BenjaminUrquhart Corrected. I apparently had some mental double-negative thing going on. ;)
    $endgroup$
    – I_P_Edwards
    9 hours ago






  • 1




    $begingroup$
    Strongly related, possible dupe
    $endgroup$
    – Giuseppe
    9 hours ago






  • 3




    $begingroup$
    @Giuseppe I don't think this is a dupe of that; the specifics of this question allow for much shorter implementations
    $endgroup$
    – ArBo
    8 hours ago














2












2








2





$begingroup$


You are given a string, which will contain ordinary a-z characters. (You can assume this will always be the case in any test, and assume that all letters will be lowercase as well). You must determine how many unique combinations can be made of the individual characters in the string, and print that number. However, duplicate letters can be ignored in counting the possible combinations. In other words, if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total.



Shortest byte count wins, looking forward to seeing some creative solutions in non-golfing languages!










share|improve this question











$endgroup$




You are given a string, which will contain ordinary a-z characters. (You can assume this will always be the case in any test, and assume that all letters will be lowercase as well). You must determine how many unique combinations can be made of the individual characters in the string, and print that number. However, duplicate letters can be ignored in counting the possible combinations. In other words, if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total.



Shortest byte count wins, looking forward to seeing some creative solutions in non-golfing languages!







code-golf string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 9 hours ago







I_P_Edwards

















asked 10 hours ago









I_P_EdwardsI_P_Edwards

1236




1236












  • $begingroup$
    However, duplicate letters cannot be ignored in counting the possible combinations - if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total. These contradict each other
    $endgroup$
    – Benjamin Urquhart
    9 hours ago










  • $begingroup$
    @BenjaminUrquhart Corrected. I apparently had some mental double-negative thing going on. ;)
    $endgroup$
    – I_P_Edwards
    9 hours ago






  • 1




    $begingroup$
    Strongly related, possible dupe
    $endgroup$
    – Giuseppe
    9 hours ago






  • 3




    $begingroup$
    @Giuseppe I don't think this is a dupe of that; the specifics of this question allow for much shorter implementations
    $endgroup$
    – ArBo
    8 hours ago


















  • $begingroup$
    However, duplicate letters cannot be ignored in counting the possible combinations - if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total. These contradict each other
    $endgroup$
    – Benjamin Urquhart
    9 hours ago










  • $begingroup$
    @BenjaminUrquhart Corrected. I apparently had some mental double-negative thing going on. ;)
    $endgroup$
    – I_P_Edwards
    9 hours ago






  • 1




    $begingroup$
    Strongly related, possible dupe
    $endgroup$
    – Giuseppe
    9 hours ago






  • 3




    $begingroup$
    @Giuseppe I don't think this is a dupe of that; the specifics of this question allow for much shorter implementations
    $endgroup$
    – ArBo
    8 hours ago
















$begingroup$
However, duplicate letters cannot be ignored in counting the possible combinations - if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total. These contradict each other
$endgroup$
– Benjamin Urquhart
9 hours ago




$begingroup$
However, duplicate letters cannot be ignored in counting the possible combinations - if the string given is "hello", then simply switching the positions of the two ls does not count as a unique phrase, and therefore cannot be counted towards the total. These contradict each other
$endgroup$
– Benjamin Urquhart
9 hours ago












$begingroup$
@BenjaminUrquhart Corrected. I apparently had some mental double-negative thing going on. ;)
$endgroup$
– I_P_Edwards
9 hours ago




$begingroup$
@BenjaminUrquhart Corrected. I apparently had some mental double-negative thing going on. ;)
$endgroup$
– I_P_Edwards
9 hours ago




1




1




$begingroup$
Strongly related, possible dupe
$endgroup$
– Giuseppe
9 hours ago




$begingroup$
Strongly related, possible dupe
$endgroup$
– Giuseppe
9 hours ago




3




3




$begingroup$
@Giuseppe I don't think this is a dupe of that; the specifics of this question allow for much shorter implementations
$endgroup$
– ArBo
8 hours ago




$begingroup$
@Giuseppe I don't think this is a dupe of that; the specifics of this question allow for much shorter implementations
$endgroup$
– ArBo
8 hours ago










13 Answers
13






active

oldest

votes


















6












$begingroup$


Python 2, 50 48 bytes





f=lambda s:s==''or len(s)*f(s[1:])/s.count(s[0])


Try it online!



No boring built-ins! To my surprise, this is even shorter than the brute force approach, calculating all of the permutations with itertools and taking the length.



This function uses the formula



$text{# of unique permutations} = frac{text{(# of elements)!}}{prod_{text{unique elements}}{text{(# of occurences of that element)!}}}$



and computes it on the fly. The factorial in the numerator is calculated by multiplying by len(s) in each function call. The denominator is a bit more subtle; in each call, we divide by the number of occurences of that element in what's left of the string, ensuring that for every character c, all numbers between 1 and the amount of occurences of c (inclusive) will be divided by exactly once. Since we divide only at the very end, we're guaranteed not to have any problems with Python 2's default floor division.






share|improve this answer











$endgroup$





















    3












    $begingroup$


    Jelly, 4 bytes



    Œ!QL


    Try it online!



    Simply does what was asked: find permutations of input, uniquify and print the length.






    share|improve this answer









    $endgroup$





















      3












      $begingroup$


      Japt, 5 bytes



      á â l


      Try it online!






      share|improve this answer









      $endgroup$













      • $begingroup$
        TIO seems to be running an old version of Japt, allowing you to ditch the â.
        $endgroup$
        – Shaggy
        6 hours ago





















      1












      $begingroup$


      R, 69 bytes





      function(s,`!`=factorial)(!nchar(s))/prod(!table(el(strsplit(s,""))))


      Try it online!



      Computes the multinomial coefficient directly.




      R, 72 bytes





      function(s,x=table(el(strsplit(s,""))))dmultinom(x,,!!x)*sum(1|x)^sum(x)


      Try it online!



      Uses the multinomial distribution function provided by dmultinom to extract the multinomial coefficient.



      Note that the usual (golfier) x<-table(el(strsplit(s,""))) doesn't work inside the dmultinom call for an unknown reason.






      share|improve this answer









      $endgroup$





















        1












        $begingroup$


        Python 2, 57 bytes





        lambda s:len(set(permutations(s)))
        from itertools import*


        Try it online!



        Self-documenting: Return the length of the set of unique permutations of the input string.




        Python 3, 55 bytes



        Credit goes to ArBo on this one:





        lambda s:len({*permutations(s)})
        from itertools import*


        Try it online!






        share|improve this answer











        $endgroup$





















          1












          $begingroup$


          Pyth, 5 bytes



          l.{.p


          Try it online!



          This assumes the input is a python string literal. If input must be raw text, this 6-byte version will work:



          l.{.pz


          Either way, it just computes all permutations of the input, converts them to a set and gets the number of elements in that set, and implicitly prints that number.






          share|improve this answer








          New contributor



          randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          $endgroup$





















            1












            $begingroup$


            CJam, 4 bytes



            le!,


            Try it online!



            Explanation



            Read line as a string (l), unique permutations as an array of strings (e!), length (,), implicit display.






            share|improve this answer











            $endgroup$





















              1












              $begingroup$


              05AB1E, 3 bytes



              œÙg


              Try it online!



              Explanation



                g  # length of the list
              Ù # of unique
              œ # permutations
              # of the input





              share|improve this answer









              $endgroup$





















                1












                $begingroup$


                MATL, 9 bytes



                jY@XuZy1)


                Try it online!



                Explanation:



                j input as string
                Y@ get permutations
                Xu unique members
                Zy size matrix
                1) first member of size matrix





                share|improve this answer









                $endgroup$









                • 1




                  $begingroup$
                  You can take the input with quotes, so j becomes i, which can be left implicit. Also, &nx saves a byte over Zy1) tio.run/##y00syfn/P9IholQtr@L/f/WM1JycfHUA
                  $endgroup$
                  – Luis Mendo
                  5 hours ago





















                1












                $begingroup$


                Octave / MATLAB, 35 bytes





                @(s)size(unique(perms(s),'rows'),1)


                Anonymous function that takes a character vector and produces a number.



                In MATLAB this can be shortened to size(unique(perms(s),'ro'),1) (33 bytes).



                Try it online!



                Explanation



                @(s)                                  % Anonymous function with input s
                perms(s) % Permutations. Gives a char matrix
                unique( ,'rows') % Deduplicate rows
                size( ,1) % Number of rows





                share|improve this answer











                $endgroup$









                • 1




                  $begingroup$
                  I thought unique returned unique rows already? Or is that only for tables?
                  $endgroup$
                  – Giuseppe
                  9 hours ago










                • $begingroup$
                  @Giuseppe For numeric/char 2D arrays unique would linearize first. For tables I think you are right; I didn't know that!
                  $endgroup$
                  – Luis Mendo
                  9 hours ago








                • 1




                  $begingroup$
                  Ah, I know where I got the idea -- unique in MATLAB does take rows for tables; R's unique takes unique rows of matrices or data frames. Too many array languages with the same commands that do slightly different things...
                  $endgroup$
                  – Giuseppe
                  5 hours ago





















                0












                $begingroup$


                APL (Dyalog Unicode), 24 bytes





                ⎕CY'dfns'
                {≢∪↓⍵[pmat≢⍵]}


                Try it online!



                Simple Dfn, takes a string as argument.



                How:



                ⎕CY'dfns'      ⍝ Copies the 'dfns' namespace.
                {≢∪↓⍵[pmat≢⍵]} ⍝ Main function
                ≢⍵ ⍝ Number of elements in the argument (⍵)
                pmat ⍝ Permutation Matrix of the range [1..≢⍵]
                ⍵[ ] ⍝ Index the argument with that matrix, which generates all permutations of ⍵
                ↓ ⍝ Convert the matrix into a vector of strings
                ∪ ⍝ Keep only the unique elements
                ≢ ⍝ Tally the number of elements





                share|improve this answer









                $endgroup$





















                  0












                  $begingroup$


                  APL (Dyalog Unicode), 14 bytes





                  !∘⍴÷⊂×.(!∘⍴∩)∪


                  Try it online!



                  Returns the result as a singleton.






                  share|improve this answer









                  $endgroup$





















                    0












                    $begingroup$


                    Retina 0.8.2, 73 bytes



                    (.)(?=(.*?1)*)
                    /1$#2$*1x1$.'$*
                    ^
                    1
                    +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                    $#2$*
                    1


                    Try it online! Uses @ArBo's formula, but evaluates from right-to-left as this can be done in integer arithmetic while still minimising the size of the unary values involved. Explanation:



                    (.)(?=(.*?1)*)
                    /1$#2$*1x1$.'$*


                    For each character, count how many remaining duplicates there are and how many further characters there are, add one to each to take the current character into account, and separate the values so we know which ones are to be divided and which are to be multiplied.



                    ^
                    1


                    Prefix a 1 to produce a complete expression.



                    +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                    $#2$*


                    Repeatedly multiply the last and third last numbers while dividing by the second last number. This replaces the last three numbers.



                    1


                    Convert to decimal.






                    share|improve this answer









                    $endgroup$














                      Your Answer






                      StackExchange.ifUsing("editor", function () {
                      StackExchange.using("externalEditor", function () {
                      StackExchange.using("snippets", function () {
                      StackExchange.snippets.init();
                      });
                      });
                      }, "code-snippets");

                      StackExchange.ready(function() {
                      var channelOptions = {
                      tags: "".split(" "),
                      id: "200"
                      };
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function() {
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled) {
                      StackExchange.using("snippets", function() {
                      createEditor();
                      });
                      }
                      else {
                      createEditor();
                      }
                      });

                      function createEditor() {
                      StackExchange.prepareEditor({
                      heartbeatType: 'answer',
                      autoActivateHeartbeat: false,
                      convertImagesToLinks: false,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: null,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader: {
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      },
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      });


                      }
                      });














                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f186996%2ffind-all-possible-unique-combinations-of-letters-in-a-word%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown

























                      13 Answers
                      13






                      active

                      oldest

                      votes








                      13 Answers
                      13






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      6












                      $begingroup$


                      Python 2, 50 48 bytes





                      f=lambda s:s==''or len(s)*f(s[1:])/s.count(s[0])


                      Try it online!



                      No boring built-ins! To my surprise, this is even shorter than the brute force approach, calculating all of the permutations with itertools and taking the length.



                      This function uses the formula



                      $text{# of unique permutations} = frac{text{(# of elements)!}}{prod_{text{unique elements}}{text{(# of occurences of that element)!}}}$



                      and computes it on the fly. The factorial in the numerator is calculated by multiplying by len(s) in each function call. The denominator is a bit more subtle; in each call, we divide by the number of occurences of that element in what's left of the string, ensuring that for every character c, all numbers between 1 and the amount of occurences of c (inclusive) will be divided by exactly once. Since we divide only at the very end, we're guaranteed not to have any problems with Python 2's default floor division.






                      share|improve this answer











                      $endgroup$


















                        6












                        $begingroup$


                        Python 2, 50 48 bytes





                        f=lambda s:s==''or len(s)*f(s[1:])/s.count(s[0])


                        Try it online!



                        No boring built-ins! To my surprise, this is even shorter than the brute force approach, calculating all of the permutations with itertools and taking the length.



                        This function uses the formula



                        $text{# of unique permutations} = frac{text{(# of elements)!}}{prod_{text{unique elements}}{text{(# of occurences of that element)!}}}$



                        and computes it on the fly. The factorial in the numerator is calculated by multiplying by len(s) in each function call. The denominator is a bit more subtle; in each call, we divide by the number of occurences of that element in what's left of the string, ensuring that for every character c, all numbers between 1 and the amount of occurences of c (inclusive) will be divided by exactly once. Since we divide only at the very end, we're guaranteed not to have any problems with Python 2's default floor division.






                        share|improve this answer











                        $endgroup$
















                          6












                          6








                          6





                          $begingroup$


                          Python 2, 50 48 bytes





                          f=lambda s:s==''or len(s)*f(s[1:])/s.count(s[0])


                          Try it online!



                          No boring built-ins! To my surprise, this is even shorter than the brute force approach, calculating all of the permutations with itertools and taking the length.



                          This function uses the formula



                          $text{# of unique permutations} = frac{text{(# of elements)!}}{prod_{text{unique elements}}{text{(# of occurences of that element)!}}}$



                          and computes it on the fly. The factorial in the numerator is calculated by multiplying by len(s) in each function call. The denominator is a bit more subtle; in each call, we divide by the number of occurences of that element in what's left of the string, ensuring that for every character c, all numbers between 1 and the amount of occurences of c (inclusive) will be divided by exactly once. Since we divide only at the very end, we're guaranteed not to have any problems with Python 2's default floor division.






                          share|improve this answer











                          $endgroup$




                          Python 2, 50 48 bytes





                          f=lambda s:s==''or len(s)*f(s[1:])/s.count(s[0])


                          Try it online!



                          No boring built-ins! To my surprise, this is even shorter than the brute force approach, calculating all of the permutations with itertools and taking the length.



                          This function uses the formula



                          $text{# of unique permutations} = frac{text{(# of elements)!}}{prod_{text{unique elements}}{text{(# of occurences of that element)!}}}$



                          and computes it on the fly. The factorial in the numerator is calculated by multiplying by len(s) in each function call. The denominator is a bit more subtle; in each call, we divide by the number of occurences of that element in what's left of the string, ensuring that for every character c, all numbers between 1 and the amount of occurences of c (inclusive) will be divided by exactly once. Since we divide only at the very end, we're guaranteed not to have any problems with Python 2's default floor division.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 7 hours ago

























                          answered 9 hours ago









                          ArBoArBo

                          96519




                          96519

























                              3












                              $begingroup$


                              Jelly, 4 bytes



                              Œ!QL


                              Try it online!



                              Simply does what was asked: find permutations of input, uniquify and print the length.






                              share|improve this answer









                              $endgroup$


















                                3












                                $begingroup$


                                Jelly, 4 bytes



                                Œ!QL


                                Try it online!



                                Simply does what was asked: find permutations of input, uniquify and print the length.






                                share|improve this answer









                                $endgroup$
















                                  3












                                  3








                                  3





                                  $begingroup$


                                  Jelly, 4 bytes



                                  Œ!QL


                                  Try it online!



                                  Simply does what was asked: find permutations of input, uniquify and print the length.






                                  share|improve this answer









                                  $endgroup$




                                  Jelly, 4 bytes



                                  Œ!QL


                                  Try it online!



                                  Simply does what was asked: find permutations of input, uniquify and print the length.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered 9 hours ago









                                  Nick KennedyNick Kennedy

                                  3,309610




                                  3,309610























                                      3












                                      $begingroup$


                                      Japt, 5 bytes



                                      á â l


                                      Try it online!






                                      share|improve this answer









                                      $endgroup$













                                      • $begingroup$
                                        TIO seems to be running an old version of Japt, allowing you to ditch the â.
                                        $endgroup$
                                        – Shaggy
                                        6 hours ago


















                                      3












                                      $begingroup$


                                      Japt, 5 bytes



                                      á â l


                                      Try it online!






                                      share|improve this answer









                                      $endgroup$













                                      • $begingroup$
                                        TIO seems to be running an old version of Japt, allowing you to ditch the â.
                                        $endgroup$
                                        – Shaggy
                                        6 hours ago
















                                      3












                                      3








                                      3





                                      $begingroup$


                                      Japt, 5 bytes



                                      á â l


                                      Try it online!






                                      share|improve this answer









                                      $endgroup$




                                      Japt, 5 bytes



                                      á â l


                                      Try it online!







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 9 hours ago









                                      Luis felipe De jesus MunozLuis felipe De jesus Munoz

                                      6,35621874




                                      6,35621874












                                      • $begingroup$
                                        TIO seems to be running an old version of Japt, allowing you to ditch the â.
                                        $endgroup$
                                        – Shaggy
                                        6 hours ago




















                                      • $begingroup$
                                        TIO seems to be running an old version of Japt, allowing you to ditch the â.
                                        $endgroup$
                                        – Shaggy
                                        6 hours ago


















                                      $begingroup$
                                      TIO seems to be running an old version of Japt, allowing you to ditch the â.
                                      $endgroup$
                                      – Shaggy
                                      6 hours ago






                                      $begingroup$
                                      TIO seems to be running an old version of Japt, allowing you to ditch the â.
                                      $endgroup$
                                      – Shaggy
                                      6 hours ago













                                      1












                                      $begingroup$


                                      R, 69 bytes





                                      function(s,`!`=factorial)(!nchar(s))/prod(!table(el(strsplit(s,""))))


                                      Try it online!



                                      Computes the multinomial coefficient directly.




                                      R, 72 bytes





                                      function(s,x=table(el(strsplit(s,""))))dmultinom(x,,!!x)*sum(1|x)^sum(x)


                                      Try it online!



                                      Uses the multinomial distribution function provided by dmultinom to extract the multinomial coefficient.



                                      Note that the usual (golfier) x<-table(el(strsplit(s,""))) doesn't work inside the dmultinom call for an unknown reason.






                                      share|improve this answer









                                      $endgroup$


















                                        1












                                        $begingroup$


                                        R, 69 bytes





                                        function(s,`!`=factorial)(!nchar(s))/prod(!table(el(strsplit(s,""))))


                                        Try it online!



                                        Computes the multinomial coefficient directly.




                                        R, 72 bytes





                                        function(s,x=table(el(strsplit(s,""))))dmultinom(x,,!!x)*sum(1|x)^sum(x)


                                        Try it online!



                                        Uses the multinomial distribution function provided by dmultinom to extract the multinomial coefficient.



                                        Note that the usual (golfier) x<-table(el(strsplit(s,""))) doesn't work inside the dmultinom call for an unknown reason.






                                        share|improve this answer









                                        $endgroup$
















                                          1












                                          1








                                          1





                                          $begingroup$


                                          R, 69 bytes





                                          function(s,`!`=factorial)(!nchar(s))/prod(!table(el(strsplit(s,""))))


                                          Try it online!



                                          Computes the multinomial coefficient directly.




                                          R, 72 bytes





                                          function(s,x=table(el(strsplit(s,""))))dmultinom(x,,!!x)*sum(1|x)^sum(x)


                                          Try it online!



                                          Uses the multinomial distribution function provided by dmultinom to extract the multinomial coefficient.



                                          Note that the usual (golfier) x<-table(el(strsplit(s,""))) doesn't work inside the dmultinom call for an unknown reason.






                                          share|improve this answer









                                          $endgroup$




                                          R, 69 bytes





                                          function(s,`!`=factorial)(!nchar(s))/prod(!table(el(strsplit(s,""))))


                                          Try it online!



                                          Computes the multinomial coefficient directly.




                                          R, 72 bytes





                                          function(s,x=table(el(strsplit(s,""))))dmultinom(x,,!!x)*sum(1|x)^sum(x)


                                          Try it online!



                                          Uses the multinomial distribution function provided by dmultinom to extract the multinomial coefficient.



                                          Note that the usual (golfier) x<-table(el(strsplit(s,""))) doesn't work inside the dmultinom call for an unknown reason.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered 9 hours ago









                                          GiuseppeGiuseppe

                                          18.6k31461




                                          18.6k31461























                                              1












                                              $begingroup$


                                              Python 2, 57 bytes





                                              lambda s:len(set(permutations(s)))
                                              from itertools import*


                                              Try it online!



                                              Self-documenting: Return the length of the set of unique permutations of the input string.




                                              Python 3, 55 bytes



                                              Credit goes to ArBo on this one:





                                              lambda s:len({*permutations(s)})
                                              from itertools import*


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$


















                                                1












                                                $begingroup$


                                                Python 2, 57 bytes





                                                lambda s:len(set(permutations(s)))
                                                from itertools import*


                                                Try it online!



                                                Self-documenting: Return the length of the set of unique permutations of the input string.




                                                Python 3, 55 bytes



                                                Credit goes to ArBo on this one:





                                                lambda s:len({*permutations(s)})
                                                from itertools import*


                                                Try it online!






                                                share|improve this answer











                                                $endgroup$
















                                                  1












                                                  1








                                                  1





                                                  $begingroup$


                                                  Python 2, 57 bytes





                                                  lambda s:len(set(permutations(s)))
                                                  from itertools import*


                                                  Try it online!



                                                  Self-documenting: Return the length of the set of unique permutations of the input string.




                                                  Python 3, 55 bytes



                                                  Credit goes to ArBo on this one:





                                                  lambda s:len({*permutations(s)})
                                                  from itertools import*


                                                  Try it online!






                                                  share|improve this answer











                                                  $endgroup$




                                                  Python 2, 57 bytes





                                                  lambda s:len(set(permutations(s)))
                                                  from itertools import*


                                                  Try it online!



                                                  Self-documenting: Return the length of the set of unique permutations of the input string.




                                                  Python 3, 55 bytes



                                                  Credit goes to ArBo on this one:





                                                  lambda s:len({*permutations(s)})
                                                  from itertools import*


                                                  Try it online!







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 9 hours ago

























                                                  answered 9 hours ago









                                                  squidsquid

                                                  4007




                                                  4007























                                                      1












                                                      $begingroup$


                                                      Pyth, 5 bytes



                                                      l.{.p


                                                      Try it online!



                                                      This assumes the input is a python string literal. If input must be raw text, this 6-byte version will work:



                                                      l.{.pz


                                                      Either way, it just computes all permutations of the input, converts them to a set and gets the number of elements in that set, and implicitly prints that number.






                                                      share|improve this answer








                                                      New contributor



                                                      randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                      Check out our Code of Conduct.





                                                      $endgroup$


















                                                        1












                                                        $begingroup$


                                                        Pyth, 5 bytes



                                                        l.{.p


                                                        Try it online!



                                                        This assumes the input is a python string literal. If input must be raw text, this 6-byte version will work:



                                                        l.{.pz


                                                        Either way, it just computes all permutations of the input, converts them to a set and gets the number of elements in that set, and implicitly prints that number.






                                                        share|improve this answer








                                                        New contributor



                                                        randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                        Check out our Code of Conduct.





                                                        $endgroup$
















                                                          1












                                                          1








                                                          1





                                                          $begingroup$


                                                          Pyth, 5 bytes



                                                          l.{.p


                                                          Try it online!



                                                          This assumes the input is a python string literal. If input must be raw text, this 6-byte version will work:



                                                          l.{.pz


                                                          Either way, it just computes all permutations of the input, converts them to a set and gets the number of elements in that set, and implicitly prints that number.






                                                          share|improve this answer








                                                          New contributor



                                                          randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                          Check out our Code of Conduct.





                                                          $endgroup$




                                                          Pyth, 5 bytes



                                                          l.{.p


                                                          Try it online!



                                                          This assumes the input is a python string literal. If input must be raw text, this 6-byte version will work:



                                                          l.{.pz


                                                          Either way, it just computes all permutations of the input, converts them to a set and gets the number of elements in that set, and implicitly prints that number.







                                                          share|improve this answer








                                                          New contributor



                                                          randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                          Check out our Code of Conduct.








                                                          share|improve this answer



                                                          share|improve this answer






                                                          New contributor



                                                          randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                          Check out our Code of Conduct.








                                                          answered 9 hours ago









                                                          randomdude999randomdude999

                                                          1817




                                                          1817




                                                          New contributor



                                                          randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                          Check out our Code of Conduct.




                                                          New contributor




                                                          randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                          Check out our Code of Conduct.

























                                                              1












                                                              $begingroup$


                                                              CJam, 4 bytes



                                                              le!,


                                                              Try it online!



                                                              Explanation



                                                              Read line as a string (l), unique permutations as an array of strings (e!), length (,), implicit display.






                                                              share|improve this answer











                                                              $endgroup$


















                                                                1












                                                                $begingroup$


                                                                CJam, 4 bytes



                                                                le!,


                                                                Try it online!



                                                                Explanation



                                                                Read line as a string (l), unique permutations as an array of strings (e!), length (,), implicit display.






                                                                share|improve this answer











                                                                $endgroup$
















                                                                  1












                                                                  1








                                                                  1





                                                                  $begingroup$


                                                                  CJam, 4 bytes



                                                                  le!,


                                                                  Try it online!



                                                                  Explanation



                                                                  Read line as a string (l), unique permutations as an array of strings (e!), length (,), implicit display.






                                                                  share|improve this answer











                                                                  $endgroup$




                                                                  CJam, 4 bytes



                                                                  le!,


                                                                  Try it online!



                                                                  Explanation



                                                                  Read line as a string (l), unique permutations as an array of strings (e!), length (,), implicit display.







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited 8 hours ago

























                                                                  answered 9 hours ago









                                                                  Luis MendoLuis Mendo

                                                                  76.2k890298




                                                                  76.2k890298























                                                                      1












                                                                      $begingroup$


                                                                      05AB1E, 3 bytes



                                                                      œÙg


                                                                      Try it online!



                                                                      Explanation



                                                                        g  # length of the list
                                                                      Ù # of unique
                                                                      œ # permutations
                                                                      # of the input





                                                                      share|improve this answer









                                                                      $endgroup$


















                                                                        1












                                                                        $begingroup$


                                                                        05AB1E, 3 bytes



                                                                        œÙg


                                                                        Try it online!



                                                                        Explanation



                                                                          g  # length of the list
                                                                        Ù # of unique
                                                                        œ # permutations
                                                                        # of the input





                                                                        share|improve this answer









                                                                        $endgroup$
















                                                                          1












                                                                          1








                                                                          1





                                                                          $begingroup$


                                                                          05AB1E, 3 bytes



                                                                          œÙg


                                                                          Try it online!



                                                                          Explanation



                                                                            g  # length of the list
                                                                          Ù # of unique
                                                                          œ # permutations
                                                                          # of the input





                                                                          share|improve this answer









                                                                          $endgroup$




                                                                          05AB1E, 3 bytes



                                                                          œÙg


                                                                          Try it online!



                                                                          Explanation



                                                                            g  # length of the list
                                                                          Ù # of unique
                                                                          œ # permutations
                                                                          # of the input






                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered 8 hours ago









                                                                          EmignaEmigna

                                                                          49.8k534150




                                                                          49.8k534150























                                                                              1












                                                                              $begingroup$


                                                                              MATL, 9 bytes



                                                                              jY@XuZy1)


                                                                              Try it online!



                                                                              Explanation:



                                                                              j input as string
                                                                              Y@ get permutations
                                                                              Xu unique members
                                                                              Zy size matrix
                                                                              1) first member of size matrix





                                                                              share|improve this answer









                                                                              $endgroup$









                                                                              • 1




                                                                                $begingroup$
                                                                                You can take the input with quotes, so j becomes i, which can be left implicit. Also, &nx saves a byte over Zy1) tio.run/##y00syfn/P9IholQtr@L/f/WM1JycfHUA
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                5 hours ago


















                                                                              1












                                                                              $begingroup$


                                                                              MATL, 9 bytes



                                                                              jY@XuZy1)


                                                                              Try it online!



                                                                              Explanation:



                                                                              j input as string
                                                                              Y@ get permutations
                                                                              Xu unique members
                                                                              Zy size matrix
                                                                              1) first member of size matrix





                                                                              share|improve this answer









                                                                              $endgroup$









                                                                              • 1




                                                                                $begingroup$
                                                                                You can take the input with quotes, so j becomes i, which can be left implicit. Also, &nx saves a byte over Zy1) tio.run/##y00syfn/P9IholQtr@L/f/WM1JycfHUA
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                5 hours ago
















                                                                              1












                                                                              1








                                                                              1





                                                                              $begingroup$


                                                                              MATL, 9 bytes



                                                                              jY@XuZy1)


                                                                              Try it online!



                                                                              Explanation:



                                                                              j input as string
                                                                              Y@ get permutations
                                                                              Xu unique members
                                                                              Zy size matrix
                                                                              1) first member of size matrix





                                                                              share|improve this answer









                                                                              $endgroup$




                                                                              MATL, 9 bytes



                                                                              jY@XuZy1)


                                                                              Try it online!



                                                                              Explanation:



                                                                              j input as string
                                                                              Y@ get permutations
                                                                              Xu unique members
                                                                              Zy size matrix
                                                                              1) first member of size matrix






                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered 7 hours ago









                                                                              OrangeCherriesOrangeCherries

                                                                              914




                                                                              914








                                                                              • 1




                                                                                $begingroup$
                                                                                You can take the input with quotes, so j becomes i, which can be left implicit. Also, &nx saves a byte over Zy1) tio.run/##y00syfn/P9IholQtr@L/f/WM1JycfHUA
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                5 hours ago
















                                                                              • 1




                                                                                $begingroup$
                                                                                You can take the input with quotes, so j becomes i, which can be left implicit. Also, &nx saves a byte over Zy1) tio.run/##y00syfn/P9IholQtr@L/f/WM1JycfHUA
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                5 hours ago










                                                                              1




                                                                              1




                                                                              $begingroup$
                                                                              You can take the input with quotes, so j becomes i, which can be left implicit. Also, &nx saves a byte over Zy1) tio.run/##y00syfn/P9IholQtr@L/f/WM1JycfHUA
                                                                              $endgroup$
                                                                              – Luis Mendo
                                                                              5 hours ago






                                                                              $begingroup$
                                                                              You can take the input with quotes, so j becomes i, which can be left implicit. Also, &nx saves a byte over Zy1) tio.run/##y00syfn/P9IholQtr@L/f/WM1JycfHUA
                                                                              $endgroup$
                                                                              – Luis Mendo
                                                                              5 hours ago













                                                                              1












                                                                              $begingroup$


                                                                              Octave / MATLAB, 35 bytes





                                                                              @(s)size(unique(perms(s),'rows'),1)


                                                                              Anonymous function that takes a character vector and produces a number.



                                                                              In MATLAB this can be shortened to size(unique(perms(s),'ro'),1) (33 bytes).



                                                                              Try it online!



                                                                              Explanation



                                                                              @(s)                                  % Anonymous function with input s
                                                                              perms(s) % Permutations. Gives a char matrix
                                                                              unique( ,'rows') % Deduplicate rows
                                                                              size( ,1) % Number of rows





                                                                              share|improve this answer











                                                                              $endgroup$









                                                                              • 1




                                                                                $begingroup$
                                                                                I thought unique returned unique rows already? Or is that only for tables?
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                9 hours ago










                                                                              • $begingroup$
                                                                                @Giuseppe For numeric/char 2D arrays unique would linearize first. For tables I think you are right; I didn't know that!
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                9 hours ago








                                                                              • 1




                                                                                $begingroup$
                                                                                Ah, I know where I got the idea -- unique in MATLAB does take rows for tables; R's unique takes unique rows of matrices or data frames. Too many array languages with the same commands that do slightly different things...
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                5 hours ago


















                                                                              1












                                                                              $begingroup$


                                                                              Octave / MATLAB, 35 bytes





                                                                              @(s)size(unique(perms(s),'rows'),1)


                                                                              Anonymous function that takes a character vector and produces a number.



                                                                              In MATLAB this can be shortened to size(unique(perms(s),'ro'),1) (33 bytes).



                                                                              Try it online!



                                                                              Explanation



                                                                              @(s)                                  % Anonymous function with input s
                                                                              perms(s) % Permutations. Gives a char matrix
                                                                              unique( ,'rows') % Deduplicate rows
                                                                              size( ,1) % Number of rows





                                                                              share|improve this answer











                                                                              $endgroup$









                                                                              • 1




                                                                                $begingroup$
                                                                                I thought unique returned unique rows already? Or is that only for tables?
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                9 hours ago










                                                                              • $begingroup$
                                                                                @Giuseppe For numeric/char 2D arrays unique would linearize first. For tables I think you are right; I didn't know that!
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                9 hours ago








                                                                              • 1




                                                                                $begingroup$
                                                                                Ah, I know where I got the idea -- unique in MATLAB does take rows for tables; R's unique takes unique rows of matrices or data frames. Too many array languages with the same commands that do slightly different things...
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                5 hours ago
















                                                                              1












                                                                              1








                                                                              1





                                                                              $begingroup$


                                                                              Octave / MATLAB, 35 bytes





                                                                              @(s)size(unique(perms(s),'rows'),1)


                                                                              Anonymous function that takes a character vector and produces a number.



                                                                              In MATLAB this can be shortened to size(unique(perms(s),'ro'),1) (33 bytes).



                                                                              Try it online!



                                                                              Explanation



                                                                              @(s)                                  % Anonymous function with input s
                                                                              perms(s) % Permutations. Gives a char matrix
                                                                              unique( ,'rows') % Deduplicate rows
                                                                              size( ,1) % Number of rows





                                                                              share|improve this answer











                                                                              $endgroup$




                                                                              Octave / MATLAB, 35 bytes





                                                                              @(s)size(unique(perms(s),'rows'),1)


                                                                              Anonymous function that takes a character vector and produces a number.



                                                                              In MATLAB this can be shortened to size(unique(perms(s),'ro'),1) (33 bytes).



                                                                              Try it online!



                                                                              Explanation



                                                                              @(s)                                  % Anonymous function with input s
                                                                              perms(s) % Permutations. Gives a char matrix
                                                                              unique( ,'rows') % Deduplicate rows
                                                                              size( ,1) % Number of rows






                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited 5 hours ago

























                                                                              answered 9 hours ago









                                                                              Luis MendoLuis Mendo

                                                                              76.2k890298




                                                                              76.2k890298








                                                                              • 1




                                                                                $begingroup$
                                                                                I thought unique returned unique rows already? Or is that only for tables?
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                9 hours ago










                                                                              • $begingroup$
                                                                                @Giuseppe For numeric/char 2D arrays unique would linearize first. For tables I think you are right; I didn't know that!
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                9 hours ago








                                                                              • 1




                                                                                $begingroup$
                                                                                Ah, I know where I got the idea -- unique in MATLAB does take rows for tables; R's unique takes unique rows of matrices or data frames. Too many array languages with the same commands that do slightly different things...
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                5 hours ago
















                                                                              • 1




                                                                                $begingroup$
                                                                                I thought unique returned unique rows already? Or is that only for tables?
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                9 hours ago










                                                                              • $begingroup$
                                                                                @Giuseppe For numeric/char 2D arrays unique would linearize first. For tables I think you are right; I didn't know that!
                                                                                $endgroup$
                                                                                – Luis Mendo
                                                                                9 hours ago








                                                                              • 1




                                                                                $begingroup$
                                                                                Ah, I know where I got the idea -- unique in MATLAB does take rows for tables; R's unique takes unique rows of matrices or data frames. Too many array languages with the same commands that do slightly different things...
                                                                                $endgroup$
                                                                                – Giuseppe
                                                                                5 hours ago










                                                                              1




                                                                              1




                                                                              $begingroup$
                                                                              I thought unique returned unique rows already? Or is that only for tables?
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              9 hours ago




                                                                              $begingroup$
                                                                              I thought unique returned unique rows already? Or is that only for tables?
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              9 hours ago












                                                                              $begingroup$
                                                                              @Giuseppe For numeric/char 2D arrays unique would linearize first. For tables I think you are right; I didn't know that!
                                                                              $endgroup$
                                                                              – Luis Mendo
                                                                              9 hours ago






                                                                              $begingroup$
                                                                              @Giuseppe For numeric/char 2D arrays unique would linearize first. For tables I think you are right; I didn't know that!
                                                                              $endgroup$
                                                                              – Luis Mendo
                                                                              9 hours ago






                                                                              1




                                                                              1




                                                                              $begingroup$
                                                                              Ah, I know where I got the idea -- unique in MATLAB does take rows for tables; R's unique takes unique rows of matrices or data frames. Too many array languages with the same commands that do slightly different things...
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              5 hours ago






                                                                              $begingroup$
                                                                              Ah, I know where I got the idea -- unique in MATLAB does take rows for tables; R's unique takes unique rows of matrices or data frames. Too many array languages with the same commands that do slightly different things...
                                                                              $endgroup$
                                                                              – Giuseppe
                                                                              5 hours ago













                                                                              0












                                                                              $begingroup$


                                                                              APL (Dyalog Unicode), 24 bytes





                                                                              ⎕CY'dfns'
                                                                              {≢∪↓⍵[pmat≢⍵]}


                                                                              Try it online!



                                                                              Simple Dfn, takes a string as argument.



                                                                              How:



                                                                              ⎕CY'dfns'      ⍝ Copies the 'dfns' namespace.
                                                                              {≢∪↓⍵[pmat≢⍵]} ⍝ Main function
                                                                              ≢⍵ ⍝ Number of elements in the argument (⍵)
                                                                              pmat ⍝ Permutation Matrix of the range [1..≢⍵]
                                                                              ⍵[ ] ⍝ Index the argument with that matrix, which generates all permutations of ⍵
                                                                              ↓ ⍝ Convert the matrix into a vector of strings
                                                                              ∪ ⍝ Keep only the unique elements
                                                                              ≢ ⍝ Tally the number of elements





                                                                              share|improve this answer









                                                                              $endgroup$


















                                                                                0












                                                                                $begingroup$


                                                                                APL (Dyalog Unicode), 24 bytes





                                                                                ⎕CY'dfns'
                                                                                {≢∪↓⍵[pmat≢⍵]}


                                                                                Try it online!



                                                                                Simple Dfn, takes a string as argument.



                                                                                How:



                                                                                ⎕CY'dfns'      ⍝ Copies the 'dfns' namespace.
                                                                                {≢∪↓⍵[pmat≢⍵]} ⍝ Main function
                                                                                ≢⍵ ⍝ Number of elements in the argument (⍵)
                                                                                pmat ⍝ Permutation Matrix of the range [1..≢⍵]
                                                                                ⍵[ ] ⍝ Index the argument with that matrix, which generates all permutations of ⍵
                                                                                ↓ ⍝ Convert the matrix into a vector of strings
                                                                                ∪ ⍝ Keep only the unique elements
                                                                                ≢ ⍝ Tally the number of elements





                                                                                share|improve this answer









                                                                                $endgroup$
















                                                                                  0












                                                                                  0








                                                                                  0





                                                                                  $begingroup$


                                                                                  APL (Dyalog Unicode), 24 bytes





                                                                                  ⎕CY'dfns'
                                                                                  {≢∪↓⍵[pmat≢⍵]}


                                                                                  Try it online!



                                                                                  Simple Dfn, takes a string as argument.



                                                                                  How:



                                                                                  ⎕CY'dfns'      ⍝ Copies the 'dfns' namespace.
                                                                                  {≢∪↓⍵[pmat≢⍵]} ⍝ Main function
                                                                                  ≢⍵ ⍝ Number of elements in the argument (⍵)
                                                                                  pmat ⍝ Permutation Matrix of the range [1..≢⍵]
                                                                                  ⍵[ ] ⍝ Index the argument with that matrix, which generates all permutations of ⍵
                                                                                  ↓ ⍝ Convert the matrix into a vector of strings
                                                                                  ∪ ⍝ Keep only the unique elements
                                                                                  ≢ ⍝ Tally the number of elements





                                                                                  share|improve this answer









                                                                                  $endgroup$




                                                                                  APL (Dyalog Unicode), 24 bytes





                                                                                  ⎕CY'dfns'
                                                                                  {≢∪↓⍵[pmat≢⍵]}


                                                                                  Try it online!



                                                                                  Simple Dfn, takes a string as argument.



                                                                                  How:



                                                                                  ⎕CY'dfns'      ⍝ Copies the 'dfns' namespace.
                                                                                  {≢∪↓⍵[pmat≢⍵]} ⍝ Main function
                                                                                  ≢⍵ ⍝ Number of elements in the argument (⍵)
                                                                                  pmat ⍝ Permutation Matrix of the range [1..≢⍵]
                                                                                  ⍵[ ] ⍝ Index the argument with that matrix, which generates all permutations of ⍵
                                                                                  ↓ ⍝ Convert the matrix into a vector of strings
                                                                                  ∪ ⍝ Keep only the unique elements
                                                                                  ≢ ⍝ Tally the number of elements






                                                                                  share|improve this answer












                                                                                  share|improve this answer



                                                                                  share|improve this answer










                                                                                  answered 8 hours ago









                                                                                  J. SalléJ. Sallé

                                                                                  2,058322




                                                                                  2,058322























                                                                                      0












                                                                                      $begingroup$


                                                                                      APL (Dyalog Unicode), 14 bytes





                                                                                      !∘⍴÷⊂×.(!∘⍴∩)∪


                                                                                      Try it online!



                                                                                      Returns the result as a singleton.






                                                                                      share|improve this answer









                                                                                      $endgroup$


















                                                                                        0












                                                                                        $begingroup$


                                                                                        APL (Dyalog Unicode), 14 bytes





                                                                                        !∘⍴÷⊂×.(!∘⍴∩)∪


                                                                                        Try it online!



                                                                                        Returns the result as a singleton.






                                                                                        share|improve this answer









                                                                                        $endgroup$
















                                                                                          0












                                                                                          0








                                                                                          0





                                                                                          $begingroup$


                                                                                          APL (Dyalog Unicode), 14 bytes





                                                                                          !∘⍴÷⊂×.(!∘⍴∩)∪


                                                                                          Try it online!



                                                                                          Returns the result as a singleton.






                                                                                          share|improve this answer









                                                                                          $endgroup$




                                                                                          APL (Dyalog Unicode), 14 bytes





                                                                                          !∘⍴÷⊂×.(!∘⍴∩)∪


                                                                                          Try it online!



                                                                                          Returns the result as a singleton.







                                                                                          share|improve this answer












                                                                                          share|improve this answer



                                                                                          share|improve this answer










                                                                                          answered 7 hours ago









                                                                                          Erik the OutgolferErik the Outgolfer

                                                                                          33.8k430107




                                                                                          33.8k430107























                                                                                              0












                                                                                              $begingroup$


                                                                                              Retina 0.8.2, 73 bytes



                                                                                              (.)(?=(.*?1)*)
                                                                                              /1$#2$*1x1$.'$*
                                                                                              ^
                                                                                              1
                                                                                              +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                              $#2$*
                                                                                              1


                                                                                              Try it online! Uses @ArBo's formula, but evaluates from right-to-left as this can be done in integer arithmetic while still minimising the size of the unary values involved. Explanation:



                                                                                              (.)(?=(.*?1)*)
                                                                                              /1$#2$*1x1$.'$*


                                                                                              For each character, count how many remaining duplicates there are and how many further characters there are, add one to each to take the current character into account, and separate the values so we know which ones are to be divided and which are to be multiplied.



                                                                                              ^
                                                                                              1


                                                                                              Prefix a 1 to produce a complete expression.



                                                                                              +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                              $#2$*


                                                                                              Repeatedly multiply the last and third last numbers while dividing by the second last number. This replaces the last three numbers.



                                                                                              1


                                                                                              Convert to decimal.






                                                                                              share|improve this answer









                                                                                              $endgroup$


















                                                                                                0












                                                                                                $begingroup$


                                                                                                Retina 0.8.2, 73 bytes



                                                                                                (.)(?=(.*?1)*)
                                                                                                /1$#2$*1x1$.'$*
                                                                                                ^
                                                                                                1
                                                                                                +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                                $#2$*
                                                                                                1


                                                                                                Try it online! Uses @ArBo's formula, but evaluates from right-to-left as this can be done in integer arithmetic while still minimising the size of the unary values involved. Explanation:



                                                                                                (.)(?=(.*?1)*)
                                                                                                /1$#2$*1x1$.'$*


                                                                                                For each character, count how many remaining duplicates there are and how many further characters there are, add one to each to take the current character into account, and separate the values so we know which ones are to be divided and which are to be multiplied.



                                                                                                ^
                                                                                                1


                                                                                                Prefix a 1 to produce a complete expression.



                                                                                                +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                                $#2$*


                                                                                                Repeatedly multiply the last and third last numbers while dividing by the second last number. This replaces the last three numbers.



                                                                                                1


                                                                                                Convert to decimal.






                                                                                                share|improve this answer









                                                                                                $endgroup$
















                                                                                                  0












                                                                                                  0








                                                                                                  0





                                                                                                  $begingroup$


                                                                                                  Retina 0.8.2, 73 bytes



                                                                                                  (.)(?=(.*?1)*)
                                                                                                  /1$#2$*1x1$.'$*
                                                                                                  ^
                                                                                                  1
                                                                                                  +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                                  $#2$*
                                                                                                  1


                                                                                                  Try it online! Uses @ArBo's formula, but evaluates from right-to-left as this can be done in integer arithmetic while still minimising the size of the unary values involved. Explanation:



                                                                                                  (.)(?=(.*?1)*)
                                                                                                  /1$#2$*1x1$.'$*


                                                                                                  For each character, count how many remaining duplicates there are and how many further characters there are, add one to each to take the current character into account, and separate the values so we know which ones are to be divided and which are to be multiplied.



                                                                                                  ^
                                                                                                  1


                                                                                                  Prefix a 1 to produce a complete expression.



                                                                                                  +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                                  $#2$*


                                                                                                  Repeatedly multiply the last and third last numbers while dividing by the second last number. This replaces the last three numbers.



                                                                                                  1


                                                                                                  Convert to decimal.






                                                                                                  share|improve this answer









                                                                                                  $endgroup$




                                                                                                  Retina 0.8.2, 73 bytes



                                                                                                  (.)(?=(.*?1)*)
                                                                                                  /1$#2$*1x1$.'$*
                                                                                                  ^
                                                                                                  1
                                                                                                  +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                                  $#2$*
                                                                                                  1


                                                                                                  Try it online! Uses @ArBo's formula, but evaluates from right-to-left as this can be done in integer arithmetic while still minimising the size of the unary values involved. Explanation:



                                                                                                  (.)(?=(.*?1)*)
                                                                                                  /1$#2$*1x1$.'$*


                                                                                                  For each character, count how many remaining duplicates there are and how many further characters there are, add one to each to take the current character into account, and separate the values so we know which ones are to be divided and which are to be multiplied.



                                                                                                  ^
                                                                                                  1


                                                                                                  Prefix a 1 to produce a complete expression.



                                                                                                  +`1(?=1*/(1+)x(1)+$)|/1+x1+$
                                                                                                  $#2$*


                                                                                                  Repeatedly multiply the last and third last numbers while dividing by the second last number. This replaces the last three numbers.



                                                                                                  1


                                                                                                  Convert to decimal.







                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered 5 hours ago









                                                                                                  NeilNeil

                                                                                                  85.3k845183




                                                                                                  85.3k845183






























                                                                                                      draft saved

                                                                                                      draft discarded




















































                                                                                                      If this is an answer to a challenge…




                                                                                                      • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                      • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                        Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                      • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                      More generally…




                                                                                                      • …Please make sure to answer the question and provide sufficient detail.


                                                                                                      • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                                      draft saved


                                                                                                      draft discarded














                                                                                                      StackExchange.ready(
                                                                                                      function () {
                                                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f186996%2ffind-all-possible-unique-combinations-of-letters-in-a-word%23new-answer', 'question_page');
                                                                                                      }
                                                                                                      );

                                                                                                      Post as a guest















                                                                                                      Required, but never shown





















































                                                                                                      Required, but never shown














                                                                                                      Required, but never shown












                                                                                                      Required, but never shown







                                                                                                      Required, but never shown

































                                                                                                      Required, but never shown














                                                                                                      Required, but never shown












                                                                                                      Required, but never shown







                                                                                                      Required, but never shown







                                                                                                      Popular posts from this blog

                                                                                                      Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                                                                                                      Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                                                                                                      Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...