How many threes?

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











up vote
6
down vote

favorite












In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,



$26042times3=78126$



and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.



Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.




Here are the first $2188$ entries in this sequence starting with zero:



1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,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3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2









share|improve this question



















  • 2




    It would be great to have some examples on the form n -> f(n), where f(n) is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
    – maxb
    32 mins ago










  • @maxb There are too many examples to do that format. My list is zero indexed.
    – W W
    31 mins ago










  • Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
    – maxb
    28 mins ago











  • Your list contains 2188 entries (~6561 / 3).
    – Arnauld
    17 mins ago










  • @maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
    – W W
    13 mins ago














up vote
6
down vote

favorite












In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,



$26042times3=78126$



and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.



Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.




Here are the first $2188$ entries in this sequence starting with zero:



1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2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,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2









share|improve this question



















  • 2




    It would be great to have some examples on the form n -> f(n), where f(n) is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
    – maxb
    32 mins ago










  • @maxb There are too many examples to do that format. My list is zero indexed.
    – W W
    31 mins ago










  • Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
    – maxb
    28 mins ago











  • Your list contains 2188 entries (~6561 / 3).
    – Arnauld
    17 mins ago










  • @maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
    – W W
    13 mins ago












up vote
6
down vote

favorite









up vote
6
down vote

favorite











In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,



$26042times3=78126$



and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.



Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.




Here are the first $2188$ entries in this sequence starting with zero:



1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,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2,2,2,3,3,3,3,2,2,2,2,2,2,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2









share|improve this question















In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,



$26042times3=78126$



and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.



Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.




Here are the first $2188$ entries in this sequence starting with zero:



1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,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2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2






code-golf sequence






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 mins ago

























asked 40 mins ago









W W

33.7k10149351




33.7k10149351







  • 2




    It would be great to have some examples on the form n -> f(n), where f(n) is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
    – maxb
    32 mins ago










  • @maxb There are too many examples to do that format. My list is zero indexed.
    – W W
    31 mins ago










  • Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
    – maxb
    28 mins ago











  • Your list contains 2188 entries (~6561 / 3).
    – Arnauld
    17 mins ago










  • @maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
    – W W
    13 mins ago












  • 2




    It would be great to have some examples on the form n -> f(n), where f(n) is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
    – maxb
    32 mins ago










  • @maxb There are too many examples to do that format. My list is zero indexed.
    – W W
    31 mins ago










  • Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
    – maxb
    28 mins ago











  • Your list contains 2188 entries (~6561 / 3).
    – Arnauld
    17 mins ago










  • @maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
    – W W
    13 mins ago







2




2




It would be great to have some examples on the form n -> f(n), where f(n) is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
– maxb
32 mins ago




It would be great to have some examples on the form n -> f(n), where f(n) is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
– maxb
32 mins ago












@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago




@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago












Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago





Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago













Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago




Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago












@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago




@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago










6 Answers
6






active

oldest

votes

















up vote
0
down vote













JavaScript (ES6), 52 bytes





n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i


Try it online!






share|improve this answer



























    up vote
    0
    down vote














    Perl 6, 54 bytes





    ($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)


    Try it online!



    Brute force solution which can't really test past n=8.






    share|improve this answer



























      up vote
      0
      down vote














      MathGolf, 15 bytes



      3*▒0ô§_3%╜0;]£


      Try it online!



      Explanation



      3* Multiply the input by 3
      ▒ Convert to a list of digits
      0 Push a zero and swap the top two elements
      ô Execute the next 6 characters for each block
      § Concatenate
      _ Duplicate
      3% Modulo 3
      ╜0 If not true, push 0
      ; Discard TOS (it's always the last zero)
      ]£ Wrap the entire stack in an array and output its length


      I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.





      share



























        up vote
        0
        down vote














        Python 2, 99 88 bytes





        lambda n:g(`3*n`)
        g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])


        Try it online!






        share|improve this answer





























          up vote
          0
          down vote













          Pyth, 16 15 bytes



          lef!.E%vT3./`*3


          Try it online here.






          share|improve this answer





























            up vote
            0
            down vote














            05AB1E, 14 12 bytes



            3*.œʒ3ÖP}€gà


            Or alternatively €gà can be éθg.



            Try it online or verify the first 1000 items






            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%2f172910%2fhow-many-threes%23new-answer', 'question_page');

              );

              Post as a guest






























              6 Answers
              6






              active

              oldest

              votes








              6 Answers
              6






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              JavaScript (ES6), 52 bytes





              n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i


              Try it online!






              share|improve this answer
























                up vote
                0
                down vote













                JavaScript (ES6), 52 bytes





                n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i


                Try it online!






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  JavaScript (ES6), 52 bytes





                  n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i


                  Try it online!






                  share|improve this answer












                  JavaScript (ES6), 52 bytes





                  n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i


                  Try it online!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 24 mins ago









                  Arnauld

                  65.1k581275




                  65.1k581275




















                      up vote
                      0
                      down vote














                      Perl 6, 54 bytes





                      ($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)


                      Try it online!



                      Brute force solution which can't really test past n=8.






                      share|improve this answer
























                        up vote
                        0
                        down vote














                        Perl 6, 54 bytes





                        ($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)


                        Try it online!



                        Brute force solution which can't really test past n=8.






                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote










                          Perl 6, 54 bytes





                          ($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)


                          Try it online!



                          Brute force solution which can't really test past n=8.






                          share|improve this answer













                          Perl 6, 54 bytes





                          ($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)


                          Try it online!



                          Brute force solution which can't really test past n=8.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 16 mins ago









                          Jo King

                          16.1k24189




                          16.1k24189




















                              up vote
                              0
                              down vote














                              MathGolf, 15 bytes



                              3*▒0ô§_3%╜0;]£


                              Try it online!



                              Explanation



                              3* Multiply the input by 3
                              ▒ Convert to a list of digits
                              0 Push a zero and swap the top two elements
                              ô Execute the next 6 characters for each block
                              § Concatenate
                              _ Duplicate
                              3% Modulo 3
                              ╜0 If not true, push 0
                              ; Discard TOS (it's always the last zero)
                              ]£ Wrap the entire stack in an array and output its length


                              I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.





                              share
























                                up vote
                                0
                                down vote














                                MathGolf, 15 bytes



                                3*▒0ô§_3%╜0;]£


                                Try it online!



                                Explanation



                                3* Multiply the input by 3
                                ▒ Convert to a list of digits
                                0 Push a zero and swap the top two elements
                                ô Execute the next 6 characters for each block
                                § Concatenate
                                _ Duplicate
                                3% Modulo 3
                                ╜0 If not true, push 0
                                ; Discard TOS (it's always the last zero)
                                ]£ Wrap the entire stack in an array and output its length


                                I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.





                                share






















                                  up vote
                                  0
                                  down vote










                                  up vote
                                  0
                                  down vote










                                  MathGolf, 15 bytes



                                  3*▒0ô§_3%╜0;]£


                                  Try it online!



                                  Explanation



                                  3* Multiply the input by 3
                                  ▒ Convert to a list of digits
                                  0 Push a zero and swap the top two elements
                                  ô Execute the next 6 characters for each block
                                  § Concatenate
                                  _ Duplicate
                                  3% Modulo 3
                                  ╜0 If not true, push 0
                                  ; Discard TOS (it's always the last zero)
                                  ]£ Wrap the entire stack in an array and output its length


                                  I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.





                                  share













                                  MathGolf, 15 bytes



                                  3*▒0ô§_3%╜0;]£


                                  Try it online!



                                  Explanation



                                  3* Multiply the input by 3
                                  ▒ Convert to a list of digits
                                  0 Push a zero and swap the top two elements
                                  ô Execute the next 6 characters for each block
                                  § Concatenate
                                  _ Duplicate
                                  3% Modulo 3
                                  ╜0 If not true, push 0
                                  ; Discard TOS (it's always the last zero)
                                  ]£ Wrap the entire stack in an array and output its length


                                  I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.






                                  share











                                  share


                                  share










                                  answered 8 mins ago









                                  maxb

                                  1,4091519




                                  1,4091519




















                                      up vote
                                      0
                                      down vote














                                      Python 2, 99 88 bytes





                                      lambda n:g(`3*n`)
                                      g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])


                                      Try it online!






                                      share|improve this answer


























                                        up vote
                                        0
                                        down vote














                                        Python 2, 99 88 bytes





                                        lambda n:g(`3*n`)
                                        g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])


                                        Try it online!






                                        share|improve this answer
























                                          up vote
                                          0
                                          down vote










                                          up vote
                                          0
                                          down vote










                                          Python 2, 99 88 bytes





                                          lambda n:g(`3*n`)
                                          g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])


                                          Try it online!






                                          share|improve this answer















                                          Python 2, 99 88 bytes





                                          lambda n:g(`3*n`)
                                          g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])


                                          Try it online!







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 6 mins ago

























                                          answered 23 mins ago









                                          TFeld

                                          11.9k2833




                                          11.9k2833




















                                              up vote
                                              0
                                              down vote













                                              Pyth, 16 15 bytes



                                              lef!.E%vT3./`*3


                                              Try it online here.






                                              share|improve this answer


























                                                up vote
                                                0
                                                down vote













                                                Pyth, 16 15 bytes



                                                lef!.E%vT3./`*3


                                                Try it online here.






                                                share|improve this answer
























                                                  up vote
                                                  0
                                                  down vote










                                                  up vote
                                                  0
                                                  down vote









                                                  Pyth, 16 15 bytes



                                                  lef!.E%vT3./`*3


                                                  Try it online here.






                                                  share|improve this answer














                                                  Pyth, 16 15 bytes



                                                  lef!.E%vT3./`*3


                                                  Try it online here.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 4 mins ago

























                                                  answered 12 mins ago









                                                  Sok

                                                  2,941722




                                                  2,941722




















                                                      up vote
                                                      0
                                                      down vote














                                                      05AB1E, 14 12 bytes



                                                      3*.œʒ3ÖP}€gà


                                                      Or alternatively €gà can be éθg.



                                                      Try it online or verify the first 1000 items






                                                      share|improve this answer


























                                                        up vote
                                                        0
                                                        down vote














                                                        05AB1E, 14 12 bytes



                                                        3*.œʒ3ÖP}€gà


                                                        Or alternatively €gà can be éθg.



                                                        Try it online or verify the first 1000 items






                                                        share|improve this answer
























                                                          up vote
                                                          0
                                                          down vote










                                                          up vote
                                                          0
                                                          down vote










                                                          05AB1E, 14 12 bytes



                                                          3*.œʒ3ÖP}€gà


                                                          Or alternatively €gà can be éθg.



                                                          Try it online or verify the first 1000 items






                                                          share|improve this answer















                                                          05AB1E, 14 12 bytes



                                                          3*.œʒ3ÖP}€gà


                                                          Or alternatively €gà can be éθg.



                                                          Try it online or verify the first 1000 items







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited 3 mins ago

























                                                          answered 13 mins ago









                                                          Kevin Cruijssen

                                                          30.5k553167




                                                          30.5k553167



























                                                               

                                                              draft saved


                                                              draft discarded















































                                                               


                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function ()
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172910%2fhow-many-threes%23new-answer', 'question_page');

                                                              );

                                                              Post as a guest













































































                                                              Comments

                                                              Popular posts from this blog

                                                              What does second last employer means? [closed]

                                                              List of Gilmore Girls characters

                                                              One-line joke