Gold nugget storage

Multi tool use
Multi tool use

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











up vote
5
down vote

favorite












Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.



Samples:



Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90


enter image description here










share|improve this question



















  • 4




    Could you give slightly more detail/put into words how the input results in the output?
    – Quintec
    9 hours ago






  • 2




    If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
    – trichoplax
    9 hours ago






  • 1




    Is it basically a sort of change-making problem ? With the coins denominations being in the set 1,9,81 × 1...64 ?
    – digEmAll
    9 hours ago







  • 1




    Are you trying to minimize the number of items or number of stacks?
    – fəˈnɛtɪk
    9 hours ago






  • 1




    @fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
    – l4m2
    9 hours ago














up vote
5
down vote

favorite












Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.



Samples:



Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90


enter image description here










share|improve this question



















  • 4




    Could you give slightly more detail/put into words how the input results in the output?
    – Quintec
    9 hours ago






  • 2




    If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
    – trichoplax
    9 hours ago






  • 1




    Is it basically a sort of change-making problem ? With the coins denominations being in the set 1,9,81 × 1...64 ?
    – digEmAll
    9 hours ago







  • 1




    Are you trying to minimize the number of items or number of stacks?
    – fəˈnɛtɪk
    9 hours ago






  • 1




    @fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
    – l4m2
    9 hours ago












up vote
5
down vote

favorite









up vote
5
down vote

favorite











Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.



Samples:



Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90


enter image description here










share|improve this question















Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.



Samples:



Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90


enter image description here







code-golf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago

























asked 9 hours ago









l4m2

4,1991432




4,1991432







  • 4




    Could you give slightly more detail/put into words how the input results in the output?
    – Quintec
    9 hours ago






  • 2




    If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
    – trichoplax
    9 hours ago






  • 1




    Is it basically a sort of change-making problem ? With the coins denominations being in the set 1,9,81 × 1...64 ?
    – digEmAll
    9 hours ago







  • 1




    Are you trying to minimize the number of items or number of stacks?
    – fəˈnɛtɪk
    9 hours ago






  • 1




    @fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
    – l4m2
    9 hours ago












  • 4




    Could you give slightly more detail/put into words how the input results in the output?
    – Quintec
    9 hours ago






  • 2




    If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
    – trichoplax
    9 hours ago






  • 1




    Is it basically a sort of change-making problem ? With the coins denominations being in the set 1,9,81 × 1...64 ?
    – digEmAll
    9 hours ago







  • 1




    Are you trying to minimize the number of items or number of stacks?
    – fəˈnɛtɪk
    9 hours ago






  • 1




    @fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
    – l4m2
    9 hours ago







4




4




Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago




Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago




2




2




If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago




If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago




1




1




Is it basically a sort of change-making problem ? With the coins denominations being in the set 1,9,81 × 1...64 ?
– digEmAll
9 hours ago





Is it basically a sort of change-making problem ? With the coins denominations being in the set 1,9,81 × 1...64 ?
– digEmAll
9 hours ago





1




1




Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago




Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago




1




1




@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago




@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago










4 Answers
4






active

oldest

votes

















up vote
3
down vote














Jelly, 17 bytes



64R×9;Ɗ⁺ff€¥@ŒṗẈṂ


Try it online!



-1 thanks to Jonathan Allan.



Explanation (you can't test for inputs larger than 58 over TIO):



64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
64R [1..64]
×9;Ɗ Multiply by 9, prepend to original list
⁺ Do the above once more
Œṗ Positive integer partitions of x
¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
f€ For each partition in x, keep the elements that are in y
f Keep the elements of x that have remained intact after the above
Ẉ Lengths of the remaining partitions
Ṃ Minimum





share|improve this answer






















  • Since the output in testable area is trivial, can't quite check?
    – l4m2
    2 hours ago

















up vote
2
down vote













JavaScript (ES6), 72 66 57 56 bytes



Saved 1 byte thanks to @nwellnhof





f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)


Try it online!






share|improve this answer






















  • @nwellnhof This would fail for several values (576, 632, 633, ...)
    – Arnauld
    4 hours ago










  • I see. But f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184) (56 bytes) should work, right?
    – nwellnhof
    3 hours ago










  • @nwellnhof Yes, it does. :)
    – Arnauld
    2 hours ago

















up vote
1
down vote














05AB1E (legacy), 30 bytes



5184‰`91SvDy64*›i1sy9*%}}64/îO


Try it online!



This is my first 05AB1E submission, so I am sure that this can be optimized.






share|improve this answer





























    up vote
    1
    down vote














    Perl 6, 47 bytes





    +($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)


    Try it online!



    A greedy algorithm seems to work.






    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: 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%2f175710%2fgold-nugget-storage%23new-answer', 'question_page');

      );

      Post as a guest






























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote














      Jelly, 17 bytes



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ


      Try it online!



      -1 thanks to Jonathan Allan.



      Explanation (you can't test for inputs larger than 58 over TIO):



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
      64R [1..64]
      ×9;Ɗ Multiply by 9, prepend to original list
      ⁺ Do the above once more
      Œṗ Positive integer partitions of x
      ¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
      f€ For each partition in x, keep the elements that are in y
      f Keep the elements of x that have remained intact after the above
      Ẉ Lengths of the remaining partitions
      Ṃ Minimum





      share|improve this answer






















      • Since the output in testable area is trivial, can't quite check?
        – l4m2
        2 hours ago














      up vote
      3
      down vote














      Jelly, 17 bytes



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ


      Try it online!



      -1 thanks to Jonathan Allan.



      Explanation (you can't test for inputs larger than 58 over TIO):



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
      64R [1..64]
      ×9;Ɗ Multiply by 9, prepend to original list
      ⁺ Do the above once more
      Œṗ Positive integer partitions of x
      ¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
      f€ For each partition in x, keep the elements that are in y
      f Keep the elements of x that have remained intact after the above
      Ẉ Lengths of the remaining partitions
      Ṃ Minimum





      share|improve this answer






















      • Since the output in testable area is trivial, can't quite check?
        – l4m2
        2 hours ago












      up vote
      3
      down vote










      up vote
      3
      down vote










      Jelly, 17 bytes



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ


      Try it online!



      -1 thanks to Jonathan Allan.



      Explanation (you can't test for inputs larger than 58 over TIO):



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
      64R [1..64]
      ×9;Ɗ Multiply by 9, prepend to original list
      ⁺ Do the above once more
      Œṗ Positive integer partitions of x
      ¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
      f€ For each partition in x, keep the elements that are in y
      f Keep the elements of x that have remained intact after the above
      Ẉ Lengths of the remaining partitions
      Ṃ Minimum





      share|improve this answer















      Jelly, 17 bytes



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ


      Try it online!



      -1 thanks to Jonathan Allan.



      Explanation (you can't test for inputs larger than 58 over TIO):



      64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
      64R [1..64]
      ×9;Ɗ Multiply by 9, prepend to original list
      ⁺ Do the above once more
      Œṗ Positive integer partitions of x
      ¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
      f€ For each partition in x, keep the elements that are in y
      f Keep the elements of x that have remained intact after the above
      Ẉ Lengths of the remaining partitions
      Ṃ Minimum






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 6 hours ago

























      answered 7 hours ago









      Erik the Outgolfer

      30.2k428100




      30.2k428100











      • Since the output in testable area is trivial, can't quite check?
        – l4m2
        2 hours ago
















      • Since the output in testable area is trivial, can't quite check?
        – l4m2
        2 hours ago















      Since the output in testable area is trivial, can't quite check?
      – l4m2
      2 hours ago




      Since the output in testable area is trivial, can't quite check?
      – l4m2
      2 hours ago










      up vote
      2
      down vote













      JavaScript (ES6), 72 66 57 56 bytes



      Saved 1 byte thanks to @nwellnhof





      f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)


      Try it online!






      share|improve this answer






















      • @nwellnhof This would fail for several values (576, 632, 633, ...)
        – Arnauld
        4 hours ago










      • I see. But f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184) (56 bytes) should work, right?
        – nwellnhof
        3 hours ago










      • @nwellnhof Yes, it does. :)
        – Arnauld
        2 hours ago














      up vote
      2
      down vote













      JavaScript (ES6), 72 66 57 56 bytes



      Saved 1 byte thanks to @nwellnhof





      f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)


      Try it online!






      share|improve this answer






















      • @nwellnhof This would fail for several values (576, 632, 633, ...)
        – Arnauld
        4 hours ago










      • I see. But f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184) (56 bytes) should work, right?
        – nwellnhof
        3 hours ago










      • @nwellnhof Yes, it does. :)
        – Arnauld
        2 hours ago












      up vote
      2
      down vote










      up vote
      2
      down vote









      JavaScript (ES6), 72 66 57 56 bytes



      Saved 1 byte thanks to @nwellnhof





      f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)


      Try it online!






      share|improve this answer














      JavaScript (ES6), 72 66 57 56 bytes



      Saved 1 byte thanks to @nwellnhof





      f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)


      Try it online!







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 2 hours ago

























      answered 8 hours ago









      Arnauld

      68.1k584288




      68.1k584288











      • @nwellnhof This would fail for several values (576, 632, 633, ...)
        – Arnauld
        4 hours ago










      • I see. But f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184) (56 bytes) should work, right?
        – nwellnhof
        3 hours ago










      • @nwellnhof Yes, it does. :)
        – Arnauld
        2 hours ago
















      • @nwellnhof This would fail for several values (576, 632, 633, ...)
        – Arnauld
        4 hours ago










      • I see. But f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184) (56 bytes) should work, right?
        – nwellnhof
        3 hours ago










      • @nwellnhof Yes, it does. :)
        – Arnauld
        2 hours ago















      @nwellnhof This would fail for several values (576, 632, 633, ...)
      – Arnauld
      4 hours ago




      @nwellnhof This would fail for several values (576, 632, 633, ...)
      – Arnauld
      4 hours ago












      I see. But f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184) (56 bytes) should work, right?
      – nwellnhof
      3 hours ago




      I see. But f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184) (56 bytes) should work, right?
      – nwellnhof
      3 hours ago












      @nwellnhof Yes, it does. :)
      – Arnauld
      2 hours ago




      @nwellnhof Yes, it does. :)
      – Arnauld
      2 hours ago










      up vote
      1
      down vote














      05AB1E (legacy), 30 bytes



      5184‰`91SvDy64*›i1sy9*%}}64/îO


      Try it online!



      This is my first 05AB1E submission, so I am sure that this can be optimized.






      share|improve this answer


























        up vote
        1
        down vote














        05AB1E (legacy), 30 bytes



        5184‰`91SvDy64*›i1sy9*%}}64/îO


        Try it online!



        This is my first 05AB1E submission, so I am sure that this can be optimized.






        share|improve this answer
























          up vote
          1
          down vote










          up vote
          1
          down vote










          05AB1E (legacy), 30 bytes



          5184‰`91SvDy64*›i1sy9*%}}64/îO


          Try it online!



          This is my first 05AB1E submission, so I am sure that this can be optimized.






          share|improve this answer















          05AB1E (legacy), 30 bytes



          5184‰`91SvDy64*›i1sy9*%}}64/îO


          Try it online!



          This is my first 05AB1E submission, so I am sure that this can be optimized.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 5 hours ago

























          answered 5 hours ago









          Black Owl Kai

          4217




          4217




















              up vote
              1
              down vote














              Perl 6, 47 bytes





              +($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)


              Try it online!



              A greedy algorithm seems to work.






              share|improve this answer
























                up vote
                1
                down vote














                Perl 6, 47 bytes





                +($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)


                Try it online!



                A greedy algorithm seems to work.






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote










                  Perl 6, 47 bytes





                  +($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)


                  Try it online!



                  A greedy algorithm seems to work.






                  share|improve this answer













                  Perl 6, 47 bytes





                  +($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)


                  Try it online!



                  A greedy algorithm seems to work.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 hours ago









                  nwellnhof

                  5,608921




                  5,608921



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175710%2fgold-nugget-storage%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      92t4He2wPuJgg4XMcelEv66 4hp9KWFAEl7 i3gEXfiHvVZHzy6PS Bie0,ZrnIroMVo6cxFn9zeyLsKS3yB2ppc21aC3M
                      Xo,TkiYcunp14bd7cPoq,y xEEBIuXrchTNaI 0,n4j0fbHIGPf47mPd1x,kPmSb3bttDBe,sC1kpyE 2ELNn5enZM

                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      How many registers does an x86_64 CPU actually have?

                      Displaying single band from multi-band raster using QGIS