Add All Permutations of a Number

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique)



For example:



10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11



202 would have 6 permutations (202, 220, 022, 022, 202, 220), so the sum would be 888.



Standard loopholes are not allowed, and as usual, since this is code golf, the shortest answer in bytes wins!










share|improve this question

















  • 1




    Note: Peter Taylor pointed out a simplification of the challenge here. If you are reading this, you may want to think about it first to see if you can get the same (or shorter) solution.
    – user202729
    4 hours ago














up vote
2
down vote

favorite












You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique)



For example:



10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11



202 would have 6 permutations (202, 220, 022, 022, 202, 220), so the sum would be 888.



Standard loopholes are not allowed, and as usual, since this is code golf, the shortest answer in bytes wins!










share|improve this question

















  • 1




    Note: Peter Taylor pointed out a simplification of the challenge here. If you are reading this, you may want to think about it first to see if you can get the same (or shorter) solution.
    – user202729
    4 hours ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique)



For example:



10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11



202 would have 6 permutations (202, 220, 022, 022, 202, 220), so the sum would be 888.



Standard loopholes are not allowed, and as usual, since this is code golf, the shortest answer in bytes wins!










share|improve this question













You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique)



For example:



10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11



202 would have 6 permutations (202, 220, 022, 022, 202, 220), so the sum would be 888.



Standard loopholes are not allowed, and as usual, since this is code golf, the shortest answer in bytes wins!







code-golf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 6 hours ago









MilkyWay90

144




144







  • 1




    Note: Peter Taylor pointed out a simplification of the challenge here. If you are reading this, you may want to think about it first to see if you can get the same (or shorter) solution.
    – user202729
    4 hours ago












  • 1




    Note: Peter Taylor pointed out a simplification of the challenge here. If you are reading this, you may want to think about it first to see if you can get the same (or shorter) solution.
    – user202729
    4 hours ago







1




1




Note: Peter Taylor pointed out a simplification of the challenge here. If you are reading this, you may want to think about it first to see if you can get the same (or shorter) solution.
– user202729
4 hours ago




Note: Peter Taylor pointed out a simplification of the challenge here. If you are reading this, you may want to think about it first to see if you can get the same (or shorter) solution.
– user202729
4 hours ago










9 Answers
9






active

oldest

votes

















up vote
1
down vote














Perl 6, 30 bytes





*.comb.permutations>>.join.sum


Try it online!



It would be nice if this was just *.permutations.sum but Perl 6 doesn't treat strings as lists of characters.



Explanation



*.comb.permutations>>.join.sum
*.comb # Convert to list of digits
.permutations # Get all permutations of the list
>>.join # Join all lists of digits
.sum # Get the sum of all numbers





share|improve this answer




















  • Nice job! I look forward to receiving more responses to this question! Since I am not familiar with Perl, the explanation was very useful!
    – MilkyWay90
    5 hours ago

















up vote
1
down vote













JavaScript (ES6), 61 bytes





n=>[...n+(x=s=p='')].map((d,i)=>(p+=1,x=x*i||1,s-=d))&&-s*p*x


Try it online!



How?



This is based on the formula suggested by Peter Taylor in the sandbox:



$$left(sum_i=1^na_iright)frac10^n-19(n-1)!$$



where $a_i$ is the $i$th digit of the input number and $n$ is the total number of digits.



The result of the expression $(10^n-1)/9$ is a number consisting of the digit $1$ repeated $n$ times, which is what is computed in $p$. The factorial is stored in $x$ and the opposite of the sum is stored in $s$.






share|improve this answer



























    up vote
    1
    down vote














    Python 2, 66 bytes





    n=s=0
    P=1
    for c in input():s+=int(c);n+=1;P*=n
    print 10**n/9*s*P/n


    Try it online!



    Takes input as a string.





    Python 2, 70 bytes





    f=lambda k,P=1,n=0,s=0:f(k/10,P*-~n,n+1,s+k%10)if k else 10**n/9*s*P/n


    Try it online!



    An arithmetic method. The base case is hard to deal with because the /n causes division by zero for the inital value n=0.






    share|improve this answer



























      up vote
      0
      down vote














      Python 2, 76 bytes





      s=map(int,`input()`);n=len(s);t=sum(s)*int('1'*n)
      while~-n:n-=1;t*=n
      print t


      Try it online!






      share|improve this answer



























        up vote
        0
        down vote














        C (clang), 86 + -lm = 89 bytes





        f(a,s,n)for(s=n=0;a;s+=a%10,a/=10,n++);a=tgamma(n)*s*(pow(10,n)-1)/9;printf("%d",a);


        Try it online!






        share|improve this answer



























          up vote
          0
          down vote














          CJam, 10 bytes



          Abm!:s1b


          Try it online!






          share|improve this answer



























            up vote
            0
            down vote














            Ruby -nl, 41 bytes





            p$_.chars.permutation.sumx


            Try it online!



            Full program taking input from stdin.




            Ruby, 45 bytes





            ->nn.digits.permutation.sumx


            Try it online!



            Function taking input as integer. digits can be shortened to chars if input is acceptable as string, and chars can be completely removed if input is an array of characters.






            share|improve this answer





























              up vote
              0
              down vote














              Python 2, 76 bytes





              lambda x:sum(map(int,x))*int('1'*len(x))*reduce(int.__mul__,range(1,len(x)))


              Try it online!



              xnor's answer is shorter, but I thought I'd have a go at a one-liner






              share|improve this answer



























                up vote
                0
                down vote














                J, 18 bytes



                1#.(A.~i.@!@#)&.":


                Try it online!



                Alternative:



                Using the formula suggested by Peter Taylor:




                J, 30 bytes



                1#.("."0*9%~!@<:@#*_1+10^#)@":


                Try it online!






                share|improve this answer






















                  Your Answer




                  StackExchange.ifUsing("editor", function ()
                  return StackExchange.using("mathjaxEditing", function ()
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                  );
                  );
                  , "mathjax-editing");

                  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',
                  convertImagesToLinks: false,
                  noModals: false,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  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%2f174335%2fadd-all-permutations-of-a-number%23new-answer', 'question_page');

                  );

                  Post as a guest






























                  9 Answers
                  9






                  active

                  oldest

                  votes








                  9 Answers
                  9






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes








                  up vote
                  1
                  down vote














                  Perl 6, 30 bytes





                  *.comb.permutations>>.join.sum


                  Try it online!



                  It would be nice if this was just *.permutations.sum but Perl 6 doesn't treat strings as lists of characters.



                  Explanation



                  *.comb.permutations>>.join.sum
                  *.comb # Convert to list of digits
                  .permutations # Get all permutations of the list
                  >>.join # Join all lists of digits
                  .sum # Get the sum of all numbers





                  share|improve this answer




















                  • Nice job! I look forward to receiving more responses to this question! Since I am not familiar with Perl, the explanation was very useful!
                    – MilkyWay90
                    5 hours ago














                  up vote
                  1
                  down vote














                  Perl 6, 30 bytes





                  *.comb.permutations>>.join.sum


                  Try it online!



                  It would be nice if this was just *.permutations.sum but Perl 6 doesn't treat strings as lists of characters.



                  Explanation



                  *.comb.permutations>>.join.sum
                  *.comb # Convert to list of digits
                  .permutations # Get all permutations of the list
                  >>.join # Join all lists of digits
                  .sum # Get the sum of all numbers





                  share|improve this answer




















                  • Nice job! I look forward to receiving more responses to this question! Since I am not familiar with Perl, the explanation was very useful!
                    – MilkyWay90
                    5 hours ago












                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote










                  Perl 6, 30 bytes





                  *.comb.permutations>>.join.sum


                  Try it online!



                  It would be nice if this was just *.permutations.sum but Perl 6 doesn't treat strings as lists of characters.



                  Explanation



                  *.comb.permutations>>.join.sum
                  *.comb # Convert to list of digits
                  .permutations # Get all permutations of the list
                  >>.join # Join all lists of digits
                  .sum # Get the sum of all numbers





                  share|improve this answer













                  Perl 6, 30 bytes





                  *.comb.permutations>>.join.sum


                  Try it online!



                  It would be nice if this was just *.permutations.sum but Perl 6 doesn't treat strings as lists of characters.



                  Explanation



                  *.comb.permutations>>.join.sum
                  *.comb # Convert to list of digits
                  .permutations # Get all permutations of the list
                  >>.join # Join all lists of digits
                  .sum # Get the sum of all numbers






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 5 hours ago









                  Jo King

                  17.5k24197




                  17.5k24197











                  • Nice job! I look forward to receiving more responses to this question! Since I am not familiar with Perl, the explanation was very useful!
                    – MilkyWay90
                    5 hours ago
















                  • Nice job! I look forward to receiving more responses to this question! Since I am not familiar with Perl, the explanation was very useful!
                    – MilkyWay90
                    5 hours ago















                  Nice job! I look forward to receiving more responses to this question! Since I am not familiar with Perl, the explanation was very useful!
                  – MilkyWay90
                  5 hours ago




                  Nice job! I look forward to receiving more responses to this question! Since I am not familiar with Perl, the explanation was very useful!
                  – MilkyWay90
                  5 hours ago










                  up vote
                  1
                  down vote













                  JavaScript (ES6), 61 bytes





                  n=>[...n+(x=s=p='')].map((d,i)=>(p+=1,x=x*i||1,s-=d))&&-s*p*x


                  Try it online!



                  How?



                  This is based on the formula suggested by Peter Taylor in the sandbox:



                  $$left(sum_i=1^na_iright)frac10^n-19(n-1)!$$



                  where $a_i$ is the $i$th digit of the input number and $n$ is the total number of digits.



                  The result of the expression $(10^n-1)/9$ is a number consisting of the digit $1$ repeated $n$ times, which is what is computed in $p$. The factorial is stored in $x$ and the opposite of the sum is stored in $s$.






                  share|improve this answer
























                    up vote
                    1
                    down vote













                    JavaScript (ES6), 61 bytes





                    n=>[...n+(x=s=p='')].map((d,i)=>(p+=1,x=x*i||1,s-=d))&&-s*p*x


                    Try it online!



                    How?



                    This is based on the formula suggested by Peter Taylor in the sandbox:



                    $$left(sum_i=1^na_iright)frac10^n-19(n-1)!$$



                    where $a_i$ is the $i$th digit of the input number and $n$ is the total number of digits.



                    The result of the expression $(10^n-1)/9$ is a number consisting of the digit $1$ repeated $n$ times, which is what is computed in $p$. The factorial is stored in $x$ and the opposite of the sum is stored in $s$.






                    share|improve this answer






















                      up vote
                      1
                      down vote










                      up vote
                      1
                      down vote









                      JavaScript (ES6), 61 bytes





                      n=>[...n+(x=s=p='')].map((d,i)=>(p+=1,x=x*i||1,s-=d))&&-s*p*x


                      Try it online!



                      How?



                      This is based on the formula suggested by Peter Taylor in the sandbox:



                      $$left(sum_i=1^na_iright)frac10^n-19(n-1)!$$



                      where $a_i$ is the $i$th digit of the input number and $n$ is the total number of digits.



                      The result of the expression $(10^n-1)/9$ is a number consisting of the digit $1$ repeated $n$ times, which is what is computed in $p$. The factorial is stored in $x$ and the opposite of the sum is stored in $s$.






                      share|improve this answer












                      JavaScript (ES6), 61 bytes





                      n=>[...n+(x=s=p='')].map((d,i)=>(p+=1,x=x*i||1,s-=d))&&-s*p*x


                      Try it online!



                      How?



                      This is based on the formula suggested by Peter Taylor in the sandbox:



                      $$left(sum_i=1^na_iright)frac10^n-19(n-1)!$$



                      where $a_i$ is the $i$th digit of the input number and $n$ is the total number of digits.



                      The result of the expression $(10^n-1)/9$ is a number consisting of the digit $1$ repeated $n$ times, which is what is computed in $p$. The factorial is stored in $x$ and the opposite of the sum is stored in $s$.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 3 hours ago









                      Arnauld

                      66.4k583280




                      66.4k583280




















                          up vote
                          1
                          down vote














                          Python 2, 66 bytes





                          n=s=0
                          P=1
                          for c in input():s+=int(c);n+=1;P*=n
                          print 10**n/9*s*P/n


                          Try it online!



                          Takes input as a string.





                          Python 2, 70 bytes





                          f=lambda k,P=1,n=0,s=0:f(k/10,P*-~n,n+1,s+k%10)if k else 10**n/9*s*P/n


                          Try it online!



                          An arithmetic method. The base case is hard to deal with because the /n causes division by zero for the inital value n=0.






                          share|improve this answer
























                            up vote
                            1
                            down vote














                            Python 2, 66 bytes





                            n=s=0
                            P=1
                            for c in input():s+=int(c);n+=1;P*=n
                            print 10**n/9*s*P/n


                            Try it online!



                            Takes input as a string.





                            Python 2, 70 bytes





                            f=lambda k,P=1,n=0,s=0:f(k/10,P*-~n,n+1,s+k%10)if k else 10**n/9*s*P/n


                            Try it online!



                            An arithmetic method. The base case is hard to deal with because the /n causes division by zero for the inital value n=0.






                            share|improve this answer






















                              up vote
                              1
                              down vote










                              up vote
                              1
                              down vote










                              Python 2, 66 bytes





                              n=s=0
                              P=1
                              for c in input():s+=int(c);n+=1;P*=n
                              print 10**n/9*s*P/n


                              Try it online!



                              Takes input as a string.





                              Python 2, 70 bytes





                              f=lambda k,P=1,n=0,s=0:f(k/10,P*-~n,n+1,s+k%10)if k else 10**n/9*s*P/n


                              Try it online!



                              An arithmetic method. The base case is hard to deal with because the /n causes division by zero for the inital value n=0.






                              share|improve this answer













                              Python 2, 66 bytes





                              n=s=0
                              P=1
                              for c in input():s+=int(c);n+=1;P*=n
                              print 10**n/9*s*P/n


                              Try it online!



                              Takes input as a string.





                              Python 2, 70 bytes





                              f=lambda k,P=1,n=0,s=0:f(k/10,P*-~n,n+1,s+k%10)if k else 10**n/9*s*P/n


                              Try it online!



                              An arithmetic method. The base case is hard to deal with because the /n causes division by zero for the inital value n=0.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 2 hours ago









                              xnor

                              87.9k17182433




                              87.9k17182433




















                                  up vote
                                  0
                                  down vote














                                  Python 2, 76 bytes





                                  s=map(int,`input()`);n=len(s);t=sum(s)*int('1'*n)
                                  while~-n:n-=1;t*=n
                                  print t


                                  Try it online!






                                  share|improve this answer
























                                    up vote
                                    0
                                    down vote














                                    Python 2, 76 bytes





                                    s=map(int,`input()`);n=len(s);t=sum(s)*int('1'*n)
                                    while~-n:n-=1;t*=n
                                    print t


                                    Try it online!






                                    share|improve this answer






















                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote










                                      Python 2, 76 bytes





                                      s=map(int,`input()`);n=len(s);t=sum(s)*int('1'*n)
                                      while~-n:n-=1;t*=n
                                      print t


                                      Try it online!






                                      share|improve this answer













                                      Python 2, 76 bytes





                                      s=map(int,`input()`);n=len(s);t=sum(s)*int('1'*n)
                                      while~-n:n-=1;t*=n
                                      print t


                                      Try it online!







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 4 hours ago









                                      Chas Brown

                                      4,4561419




                                      4,4561419




















                                          up vote
                                          0
                                          down vote














                                          C (clang), 86 + -lm = 89 bytes





                                          f(a,s,n)for(s=n=0;a;s+=a%10,a/=10,n++);a=tgamma(n)*s*(pow(10,n)-1)/9;printf("%d",a);


                                          Try it online!






                                          share|improve this answer
























                                            up vote
                                            0
                                            down vote














                                            C (clang), 86 + -lm = 89 bytes





                                            f(a,s,n)for(s=n=0;a;s+=a%10,a/=10,n++);a=tgamma(n)*s*(pow(10,n)-1)/9;printf("%d",a);


                                            Try it online!






                                            share|improve this answer






















                                              up vote
                                              0
                                              down vote










                                              up vote
                                              0
                                              down vote










                                              C (clang), 86 + -lm = 89 bytes





                                              f(a,s,n)for(s=n=0;a;s+=a%10,a/=10,n++);a=tgamma(n)*s*(pow(10,n)-1)/9;printf("%d",a);


                                              Try it online!






                                              share|improve this answer













                                              C (clang), 86 + -lm = 89 bytes





                                              f(a,s,n)for(s=n=0;a;s+=a%10,a/=10,n++);a=tgamma(n)*s*(pow(10,n)-1)/9;printf("%d",a);


                                              Try it online!







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered 3 hours ago









                                              Logern

                                              39115




                                              39115




















                                                  up vote
                                                  0
                                                  down vote














                                                  CJam, 10 bytes



                                                  Abm!:s1b


                                                  Try it online!






                                                  share|improve this answer
























                                                    up vote
                                                    0
                                                    down vote














                                                    CJam, 10 bytes



                                                    Abm!:s1b


                                                    Try it online!






                                                    share|improve this answer






















                                                      up vote
                                                      0
                                                      down vote










                                                      up vote
                                                      0
                                                      down vote










                                                      CJam, 10 bytes



                                                      Abm!:s1b


                                                      Try it online!






                                                      share|improve this answer













                                                      CJam, 10 bytes



                                                      Abm!:s1b


                                                      Try it online!







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered 53 mins ago









                                                      Esolanging Fruit

                                                      8,11932373




                                                      8,11932373




















                                                          up vote
                                                          0
                                                          down vote














                                                          Ruby -nl, 41 bytes





                                                          p$_.chars.permutation.sumx


                                                          Try it online!



                                                          Full program taking input from stdin.




                                                          Ruby, 45 bytes





                                                          ->nn.digits.permutation.sumx


                                                          Try it online!



                                                          Function taking input as integer. digits can be shortened to chars if input is acceptable as string, and chars can be completely removed if input is an array of characters.






                                                          share|improve this answer


























                                                            up vote
                                                            0
                                                            down vote














                                                            Ruby -nl, 41 bytes





                                                            p$_.chars.permutation.sumx


                                                            Try it online!



                                                            Full program taking input from stdin.




                                                            Ruby, 45 bytes





                                                            ->nn.digits.permutation.sumx


                                                            Try it online!



                                                            Function taking input as integer. digits can be shortened to chars if input is acceptable as string, and chars can be completely removed if input is an array of characters.






                                                            share|improve this answer
























                                                              up vote
                                                              0
                                                              down vote










                                                              up vote
                                                              0
                                                              down vote










                                                              Ruby -nl, 41 bytes





                                                              p$_.chars.permutation.sumx


                                                              Try it online!



                                                              Full program taking input from stdin.




                                                              Ruby, 45 bytes





                                                              ->nn.digits.permutation.sumx


                                                              Try it online!



                                                              Function taking input as integer. digits can be shortened to chars if input is acceptable as string, and chars can be completely removed if input is an array of characters.






                                                              share|improve this answer















                                                              Ruby -nl, 41 bytes





                                                              p$_.chars.permutation.sumx


                                                              Try it online!



                                                              Full program taking input from stdin.




                                                              Ruby, 45 bytes





                                                              ->nn.digits.permutation.sumx


                                                              Try it online!



                                                              Function taking input as integer. digits can be shortened to chars if input is acceptable as string, and chars can be completely removed if input is an array of characters.







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited 33 mins ago

























                                                              answered 44 mins ago









                                                              Kirill L.

                                                              2,9261117




                                                              2,9261117




















                                                                  up vote
                                                                  0
                                                                  down vote














                                                                  Python 2, 76 bytes





                                                                  lambda x:sum(map(int,x))*int('1'*len(x))*reduce(int.__mul__,range(1,len(x)))


                                                                  Try it online!



                                                                  xnor's answer is shorter, but I thought I'd have a go at a one-liner






                                                                  share|improve this answer
























                                                                    up vote
                                                                    0
                                                                    down vote














                                                                    Python 2, 76 bytes





                                                                    lambda x:sum(map(int,x))*int('1'*len(x))*reduce(int.__mul__,range(1,len(x)))


                                                                    Try it online!



                                                                    xnor's answer is shorter, but I thought I'd have a go at a one-liner






                                                                    share|improve this answer






















                                                                      up vote
                                                                      0
                                                                      down vote










                                                                      up vote
                                                                      0
                                                                      down vote










                                                                      Python 2, 76 bytes





                                                                      lambda x:sum(map(int,x))*int('1'*len(x))*reduce(int.__mul__,range(1,len(x)))


                                                                      Try it online!



                                                                      xnor's answer is shorter, but I thought I'd have a go at a one-liner






                                                                      share|improve this answer













                                                                      Python 2, 76 bytes





                                                                      lambda x:sum(map(int,x))*int('1'*len(x))*reduce(int.__mul__,range(1,len(x)))


                                                                      Try it online!



                                                                      xnor's answer is shorter, but I thought I'd have a go at a one-liner







                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered 31 mins ago









                                                                      Jo King

                                                                      17.5k24197




                                                                      17.5k24197




















                                                                          up vote
                                                                          0
                                                                          down vote














                                                                          J, 18 bytes



                                                                          1#.(A.~i.@!@#)&.":


                                                                          Try it online!



                                                                          Alternative:



                                                                          Using the formula suggested by Peter Taylor:




                                                                          J, 30 bytes



                                                                          1#.("."0*9%~!@<:@#*_1+10^#)@":


                                                                          Try it online!






                                                                          share|improve this answer


























                                                                            up vote
                                                                            0
                                                                            down vote














                                                                            J, 18 bytes



                                                                            1#.(A.~i.@!@#)&.":


                                                                            Try it online!



                                                                            Alternative:



                                                                            Using the formula suggested by Peter Taylor:




                                                                            J, 30 bytes



                                                                            1#.("."0*9%~!@<:@#*_1+10^#)@":


                                                                            Try it online!






                                                                            share|improve this answer
























                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              J, 18 bytes



                                                                              1#.(A.~i.@!@#)&.":


                                                                              Try it online!



                                                                              Alternative:



                                                                              Using the formula suggested by Peter Taylor:




                                                                              J, 30 bytes



                                                                              1#.("."0*9%~!@<:@#*_1+10^#)@":


                                                                              Try it online!






                                                                              share|improve this answer















                                                                              J, 18 bytes



                                                                              1#.(A.~i.@!@#)&.":


                                                                              Try it online!



                                                                              Alternative:



                                                                              Using the formula suggested by Peter Taylor:




                                                                              J, 30 bytes



                                                                              1#.("."0*9%~!@<:@#*_1+10^#)@":


                                                                              Try it online!







                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited 2 mins ago

























                                                                              answered 17 mins ago









                                                                              Galen Ivanov

                                                                              5,3021931




                                                                              5,3021931



























                                                                                   

                                                                                  draft saved


                                                                                  draft discarded















































                                                                                   


                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function ()
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f174335%2fadd-all-permutations-of-a-number%23new-answer', 'question_page');

                                                                                  );

                                                                                  Post as a guest













































































                                                                                  Comments

                                                                                  Popular posts from this blog

                                                                                  List of Gilmore Girls characters

                                                                                  What does second last employer means? [closed]

                                                                                  One-line joke