Chunk + Enumerate a list of digitsOutput all numbers below certain number containing certain digitsMake a numeric list converterOutput the Partial ProductsNested Header ListExpand shorthand increasing integer sequencesSplit a byte array into a bit arrayRuns of Digits in PiFind the numbers and calculate outputFill in an increasing sequence with as many numbers as possibleReorder a Master List Based on a Reordered Subset

Why did IBM make public the PC BIOS source code?

What is the farthest a camera can see?

Are there really no countries that protect Freedom of Speech as the United States does?

How would you translate this? バタコチーズライス

Installing Windows to flash BIOS, then reinstalling Ubuntu

A torrent of foreign terms

The cat ate your input again!

Clarification on Integrability

PhD advisor lost funding, need advice

Beginner in need of a simple explanation of the difference between order of evaluation and precedence/associativity

How do you deal with the emotions of not being the one to find the cause of a bug?

Can the IPA represent all languages' tones?

Corroded Metal vs Magical Armor, should it melt it?

Is there any way to stop a user from creating executables and running them?

Website error: "Walmart can’t use this browser"

Are there any other rule mechanics that could grant Thieves' Cant?

Are differences between uniformly distributed numbers uniformly distributed?

If you know the location of an invisible creature, can you attack it?

Does Nightpack Ambusher's second ability trigger if I cast spells during the end step?

How do I call a 6-digit Australian phone number with a US-based mobile phone?

Do Reform Jews believe in a theistic God?

Word for an event that will likely never happen again

How far did Gandalf and the Balrog drop from the bridge in Moria?

How can God warn people of the upcoming rapture without disrupting society?



Chunk + Enumerate a list of digits


Output all numbers below certain number containing certain digitsMake a numeric list converterOutput the Partial ProductsNested Header ListExpand shorthand increasing integer sequencesSplit a byte array into a bit arrayRuns of Digits in PiFind the numbers and calculate outputFill in an increasing sequence with as many numbers as possibleReorder a Master List Based on a Reordered Subset






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








5












$begingroup$


I have a list of decimal digits:



4, 4, 4, 7, 7, 9, 9, 9, 9, 2, 2, 2, 4, 4



The list of decimal digits are known as items. We can form "chunks" from these items by grouping together identical and adjacent numbers. I want to assign each chunk a unique number, starting from 1, and increasing by 1 in the order the chunks appear in the original list. So, the output for the given example would look like this:



1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5



Input format



A list of digits (0-9) separated by a comma, then a space. Encoding: ASCII



Output format



A series of decimal numbers, separated by a delimiter. Your program must always use the same delimiter. The delimiter must be longer than 0 bits. Encoding: ASCII



Standard loopholes apply.










share|improve this question











$endgroup$









  • 4




    $begingroup$
    Any particular reason for the strict input and output format?
    $endgroup$
    – Unrelated String
    8 hours ago






  • 2




    $begingroup$
    @UnrelatedString Hmm, I shall loosen them.
    $endgroup$
    – noɥʇʎԀʎzɐɹƆ
    8 hours ago










  • $begingroup$
    Can the output start from 0 instead?
    $endgroup$
    – Embodiment of Ignorance
    8 hours ago






  • 2




    $begingroup$
    The IO is still rather strict. Can't you just say "input and output is as a list" and let the site defaults take care of it for you?
    $endgroup$
    – Jo King
    2 hours ago






  • 1




    $begingroup$
    Can we assume the list is non-empty?
    $endgroup$
    – Jo King
    1 hour ago

















5












$begingroup$


I have a list of decimal digits:



4, 4, 4, 7, 7, 9, 9, 9, 9, 2, 2, 2, 4, 4



The list of decimal digits are known as items. We can form "chunks" from these items by grouping together identical and adjacent numbers. I want to assign each chunk a unique number, starting from 1, and increasing by 1 in the order the chunks appear in the original list. So, the output for the given example would look like this:



1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5



Input format



A list of digits (0-9) separated by a comma, then a space. Encoding: ASCII



Output format



A series of decimal numbers, separated by a delimiter. Your program must always use the same delimiter. The delimiter must be longer than 0 bits. Encoding: ASCII



Standard loopholes apply.










share|improve this question











$endgroup$









  • 4




    $begingroup$
    Any particular reason for the strict input and output format?
    $endgroup$
    – Unrelated String
    8 hours ago






  • 2




    $begingroup$
    @UnrelatedString Hmm, I shall loosen them.
    $endgroup$
    – noɥʇʎԀʎzɐɹƆ
    8 hours ago










  • $begingroup$
    Can the output start from 0 instead?
    $endgroup$
    – Embodiment of Ignorance
    8 hours ago






  • 2




    $begingroup$
    The IO is still rather strict. Can't you just say "input and output is as a list" and let the site defaults take care of it for you?
    $endgroup$
    – Jo King
    2 hours ago






  • 1




    $begingroup$
    Can we assume the list is non-empty?
    $endgroup$
    – Jo King
    1 hour ago













5












5








5





$begingroup$


I have a list of decimal digits:



4, 4, 4, 7, 7, 9, 9, 9, 9, 2, 2, 2, 4, 4



The list of decimal digits are known as items. We can form "chunks" from these items by grouping together identical and adjacent numbers. I want to assign each chunk a unique number, starting from 1, and increasing by 1 in the order the chunks appear in the original list. So, the output for the given example would look like this:



1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5



Input format



A list of digits (0-9) separated by a comma, then a space. Encoding: ASCII



Output format



A series of decimal numbers, separated by a delimiter. Your program must always use the same delimiter. The delimiter must be longer than 0 bits. Encoding: ASCII



Standard loopholes apply.










share|improve this question











$endgroup$




I have a list of decimal digits:



4, 4, 4, 7, 7, 9, 9, 9, 9, 2, 2, 2, 4, 4



The list of decimal digits are known as items. We can form "chunks" from these items by grouping together identical and adjacent numbers. I want to assign each chunk a unique number, starting from 1, and increasing by 1 in the order the chunks appear in the original list. So, the output for the given example would look like this:



1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5



Input format



A list of digits (0-9) separated by a comma, then a space. Encoding: ASCII



Output format



A series of decimal numbers, separated by a delimiter. Your program must always use the same delimiter. The delimiter must be longer than 0 bits. Encoding: ASCII



Standard loopholes apply.







code-golf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago







noɥʇʎԀʎzɐɹƆ

















asked 8 hours ago









noɥʇʎԀʎzɐɹƆnoɥʇʎԀʎzɐɹƆ

4981 gold badge9 silver badges28 bronze badges




4981 gold badge9 silver badges28 bronze badges










  • 4




    $begingroup$
    Any particular reason for the strict input and output format?
    $endgroup$
    – Unrelated String
    8 hours ago






  • 2




    $begingroup$
    @UnrelatedString Hmm, I shall loosen them.
    $endgroup$
    – noɥʇʎԀʎzɐɹƆ
    8 hours ago










  • $begingroup$
    Can the output start from 0 instead?
    $endgroup$
    – Embodiment of Ignorance
    8 hours ago






  • 2




    $begingroup$
    The IO is still rather strict. Can't you just say "input and output is as a list" and let the site defaults take care of it for you?
    $endgroup$
    – Jo King
    2 hours ago






  • 1




    $begingroup$
    Can we assume the list is non-empty?
    $endgroup$
    – Jo King
    1 hour ago












  • 4




    $begingroup$
    Any particular reason for the strict input and output format?
    $endgroup$
    – Unrelated String
    8 hours ago






  • 2




    $begingroup$
    @UnrelatedString Hmm, I shall loosen them.
    $endgroup$
    – noɥʇʎԀʎzɐɹƆ
    8 hours ago










  • $begingroup$
    Can the output start from 0 instead?
    $endgroup$
    – Embodiment of Ignorance
    8 hours ago






  • 2




    $begingroup$
    The IO is still rather strict. Can't you just say "input and output is as a list" and let the site defaults take care of it for you?
    $endgroup$
    – Jo King
    2 hours ago






  • 1




    $begingroup$
    Can we assume the list is non-empty?
    $endgroup$
    – Jo King
    1 hour ago







4




4




$begingroup$
Any particular reason for the strict input and output format?
$endgroup$
– Unrelated String
8 hours ago




$begingroup$
Any particular reason for the strict input and output format?
$endgroup$
– Unrelated String
8 hours ago




2




2




$begingroup$
@UnrelatedString Hmm, I shall loosen them.
$endgroup$
– noɥʇʎԀʎzɐɹƆ
8 hours ago




$begingroup$
@UnrelatedString Hmm, I shall loosen them.
$endgroup$
– noɥʇʎԀʎzɐɹƆ
8 hours ago












$begingroup$
Can the output start from 0 instead?
$endgroup$
– Embodiment of Ignorance
8 hours ago




$begingroup$
Can the output start from 0 instead?
$endgroup$
– Embodiment of Ignorance
8 hours ago




2




2




$begingroup$
The IO is still rather strict. Can't you just say "input and output is as a list" and let the site defaults take care of it for you?
$endgroup$
– Jo King
2 hours ago




$begingroup$
The IO is still rather strict. Can't you just say "input and output is as a list" and let the site defaults take care of it for you?
$endgroup$
– Jo King
2 hours ago




1




1




$begingroup$
Can we assume the list is non-empty?
$endgroup$
– Jo King
1 hour ago




$begingroup$
Can we assume the list is non-empty?
$endgroup$
– Jo King
1 hour ago










19 Answers
19






active

oldest

votes


















2












$begingroup$


APL (dzaima/APL), 7 bytesSBCS





Anonymous tacit prefix function. Prints space-separated.



+1,2≠/


Try it online!



2≠/ pair-wise inequality



1, prepend 1



+ cumulative sum






share|improve this answer









$endgroup$






















    2












    $begingroup$


    Python 2, 44 bytes





    l=input()
    n=0
    for i in l:n+=i!=l;l=i;print n


    Try it online!






    share|improve this answer











    $endgroup$






















      1












      $begingroup$

      JavaScript (ES6), 30 bytes





      a=>a.map(p=n=>i+=p!=(p=n),i=0)


      Try it online!






      share|improve this answer









      $endgroup$






















        1












        $begingroup$


        Jelly, 6 5 bytes



        ŒɠµJx


        Try it online!



        Saved one byte thanks to UnrelatedString!



        Inputs and outputs as array's (with opening/closing brackets)



        How it works



        ŒɠµJx - Main link, takes one argument: [7, 7, 5, 5, 5, 1]
        Œɠ - Get the lengths of consecutive elements: [2, 3, 1]
        µ - Call these lengths A
        J - range(length(A)) [1, 2, 3]
        x - Repeat each element by the corresponding value in A: [1, 1, 2, 2, 2, 3]





        share|improve this answer











        $endgroup$














        • $begingroup$
          5 bytes
          $endgroup$
          – Unrelated String
          8 hours ago






        • 1




          $begingroup$
          @UnrelatedString all these new-fangled atoms!
          $endgroup$
          – caird coinheringaahing
          8 hours ago


















        1












        $begingroup$


        Perl 5, 27 bytes





        s/d/$i+=$&!=$l;$l=$&;$i/ge


        Try it online!






        share|improve this answer









        $endgroup$






















          1












          $begingroup$


          Octave / MATLAB, 25 bytes





          @(x)cumsum([1 ~~diff(x)])


          Try it online!






          share|improve this answer









          $endgroup$






















            1












            $begingroup$


            Wolfram Language (Mathematica), 29 bytes



            Join@@(i=1;0#+i++&/@Split@#)&


            Try it online!






            share|improve this answer









            $endgroup$






















              1












              $begingroup$


              Jelly, 5 bytes



              nƝÄŻ‘


              Try it online!



              I initially aimed for a 4-byter (the same program but without the Ż) but then quickly realized that a 1 had to be prepended every time due to an oversight... Even though there is another 5-byter in Jelly, I'll actually keep this because it uses a different method.



              For each pair of neighbouring items of the input list $L$, test if $L_ine L_i+1, forall 1le i<|L|$ and save these results in a list. Then take the cumulative sum of this list and increment them by 1 to match the chunk indexing system. TL;DR. Whenever we encounter different neighbouring items, we increment the chunk index by 1.






              share|improve this answer











              $endgroup$






















                1












                $begingroup$


                Python 3.8 (pre-release), 41 bytes





                lambda l,n=0:[n:=n+(l!=(l:=x))for x in l]


                Try it online!



                Praise the magic walrus := of assignment expressions.





                Python 2, 42 bytes





                n=0
                for x in input():n+=x!=id;id=x;print n


                Try it online!






                share|improve this answer









                $endgroup$














                • $begingroup$
                  Hmm, how long would this be in Pyth?
                  $endgroup$
                  – noɥʇʎԀʎzɐɹƆ
                  5 hours ago


















                1












                $begingroup$


                Haskell, 40 bytes





                f(a:t)=1:map(+sum[1|a/=t!!0])(f t)
                f e=e


                Try it online!






                share|improve this answer









                $endgroup$






















                  0












                  $begingroup$


                  Japt v2.0a0, 9 bytes



                  £T±A¦(A=X


                  Try it






                  share|improve this answer









                  $endgroup$






















                    0












                    $begingroup$


                    Add++, 23 bytes



                    D,f,@*,BGd€bL$bLRz€¦XBF


                    Try it online!



                    How it works



                    D,f,@*, - Define a function, f, that takes one argument: [7 7 5 5 5 1]
                    BG - Group neighbouring elements together: [[[7 7] [5 5 5] [1]]]
                    d - Duplicate: [[[7 7] [5 5 5] [1]] [[7 7] [5 5 5] [1]]]
                    €bL - Get the length of each: [[[7 7] [5 5 5] [1]] [2 3 1]]
                    $bLR - Length, then range of length: [[2 3 1] [1 2 3]]
                    z - Zip together: [[2 1] [3 2] [1 3]]
                    €¦X - Reduce each by repetition: [[1 1] [2 2 2] [3]]
                    BF - Flatten: [1 1 2 2 2 3]
                    - Due to the * in the function definition,
                    return the whole stack: [1 1 2 2 2 3]





                    share|improve this answer









                    $endgroup$






















                      0












                      $begingroup$


                      Japt, 8 7 bytes



                      ä¦Ug)åÄ


                      Try it






                      share|improve this answer











                      $endgroup$






















                        0












                        $begingroup$


                        Retina 0.8.2, 34 bytes



                        bd+b(?<=(b(3|(d+))D*)*)
                        $#3


                        Try it online! Explanation:



                        bd+b


                        Match each number in turn.



                        (?<=(...)*)


                        Start looking backwards for as many matches as possible. (The next entries will be in right-to-left order as that's how lookbehind works.)



                        D*


                        Skip the separators.



                        (3|(d+))


                        Try to match the same number as last time, but failing that, just match any number, but remember that we had to match a new number.



                        b


                        Ensure the whole number is matched.



                        $#3


                        Count the number of new numbers.






                        share|improve this answer









                        $endgroup$






















                          0












                          $begingroup$


                          05AB1E, 5 bytes



                          ¥Ā.¥>


                          Try it online!






                          share|improve this answer









                          $endgroup$






















                            0












                            $begingroup$


                            Stax, 10 bytes



                            ▓ª2ªmD?Ä╧╖


                            Run and debug it



                            The output uses space as a delimiter. The input follows the precise specifications using commas as separators, and now enclosing braces.






                            share|improve this answer











                            $endgroup$






















                              0












                              $begingroup$


                              C (gcc), 62 61 bytes



                              This is one of the few entries I've done where a complete program is shorter than a function submission!



                              On the first pass, I don't care about the previous value, so I get to rely on the fact that argv is a pointer to somewhere and is extremely unlikely to be between [0..9]!





                              s;main(i,j)for(;~scanf("%d,",&i);j=i)printf("%d ",s+=j!=i);


                              Try it online!






                              share|improve this answer











                              $endgroup$






















                                0












                                $begingroup$


                                Perl 6, 21 bytes





                                +<<[+] $,


                                Try it online!



                                Anonymous code block that takes a list and returns a list. This works by comparing whether each pair of adjacent elements are not equal, than taking the cumulative sum of the list.






                                share|improve this answer









                                $endgroup$






















                                  0












                                  $begingroup$


                                  Haskell, 46 43 bytes





                                  scanl(+)1.map fromEnum.(zipWith(/=)=<<tail)


                                  Try it online!



                                  Anonymous pointfree function that takes a list and returns a list






                                  share|improve this answer











                                  $endgroup$

















                                    Your Answer






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

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

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

                                    else
                                    createEditor();

                                    );

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



                                    );













                                    draft saved

                                    draft discarded


















                                    StackExchange.ready(
                                    function ()
                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f189932%2fchunk-enumerate-a-list-of-digits%23new-answer', 'question_page');

                                    );

                                    Post as a guest















                                    Required, but never shown

























                                    19 Answers
                                    19






                                    active

                                    oldest

                                    votes








                                    19 Answers
                                    19






                                    active

                                    oldest

                                    votes









                                    active

                                    oldest

                                    votes






                                    active

                                    oldest

                                    votes









                                    2












                                    $begingroup$


                                    APL (dzaima/APL), 7 bytesSBCS





                                    Anonymous tacit prefix function. Prints space-separated.



                                    +1,2≠/


                                    Try it online!



                                    2≠/ pair-wise inequality



                                    1, prepend 1



                                    + cumulative sum






                                    share|improve this answer









                                    $endgroup$



















                                      2












                                      $begingroup$


                                      APL (dzaima/APL), 7 bytesSBCS





                                      Anonymous tacit prefix function. Prints space-separated.



                                      +1,2≠/


                                      Try it online!



                                      2≠/ pair-wise inequality



                                      1, prepend 1



                                      + cumulative sum






                                      share|improve this answer









                                      $endgroup$

















                                        2












                                        2








                                        2





                                        $begingroup$


                                        APL (dzaima/APL), 7 bytesSBCS





                                        Anonymous tacit prefix function. Prints space-separated.



                                        +1,2≠/


                                        Try it online!



                                        2≠/ pair-wise inequality



                                        1, prepend 1



                                        + cumulative sum






                                        share|improve this answer









                                        $endgroup$




                                        APL (dzaima/APL), 7 bytesSBCS





                                        Anonymous tacit prefix function. Prints space-separated.



                                        +1,2≠/


                                        Try it online!



                                        2≠/ pair-wise inequality



                                        1, prepend 1



                                        + cumulative sum







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 7 hours ago









                                        AdámAdám

                                        29.5k2 gold badges79 silver badges212 bronze badges




                                        29.5k2 gold badges79 silver badges212 bronze badges


























                                            2












                                            $begingroup$


                                            Python 2, 44 bytes





                                            l=input()
                                            n=0
                                            for i in l:n+=i!=l;l=i;print n


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$



















                                              2












                                              $begingroup$


                                              Python 2, 44 bytes





                                              l=input()
                                              n=0
                                              for i in l:n+=i!=l;l=i;print n


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$

















                                                2












                                                2








                                                2





                                                $begingroup$


                                                Python 2, 44 bytes





                                                l=input()
                                                n=0
                                                for i in l:n+=i!=l;l=i;print n


                                                Try it online!






                                                share|improve this answer











                                                $endgroup$




                                                Python 2, 44 bytes





                                                l=input()
                                                n=0
                                                for i in l:n+=i!=l;l=i;print n


                                                Try it online!







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 7 hours ago

























                                                answered 7 hours ago









                                                Erik the OutgolferErik the Outgolfer

                                                35.5k4 gold badges30 silver badges110 bronze badges




                                                35.5k4 gold badges30 silver badges110 bronze badges
























                                                    1












                                                    $begingroup$

                                                    JavaScript (ES6), 30 bytes





                                                    a=>a.map(p=n=>i+=p!=(p=n),i=0)


                                                    Try it online!






                                                    share|improve this answer









                                                    $endgroup$



















                                                      1












                                                      $begingroup$

                                                      JavaScript (ES6), 30 bytes





                                                      a=>a.map(p=n=>i+=p!=(p=n),i=0)


                                                      Try it online!






                                                      share|improve this answer









                                                      $endgroup$

















                                                        1












                                                        1








                                                        1





                                                        $begingroup$

                                                        JavaScript (ES6), 30 bytes





                                                        a=>a.map(p=n=>i+=p!=(p=n),i=0)


                                                        Try it online!






                                                        share|improve this answer









                                                        $endgroup$



                                                        JavaScript (ES6), 30 bytes





                                                        a=>a.map(p=n=>i+=p!=(p=n),i=0)


                                                        Try it online!







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered 8 hours ago









                                                        ArnauldArnauld

                                                        89.8k7 gold badges104 silver badges366 bronze badges




                                                        89.8k7 gold badges104 silver badges366 bronze badges
























                                                            1












                                                            $begingroup$


                                                            Jelly, 6 5 bytes



                                                            ŒɠµJx


                                                            Try it online!



                                                            Saved one byte thanks to UnrelatedString!



                                                            Inputs and outputs as array's (with opening/closing brackets)



                                                            How it works



                                                            ŒɠµJx - Main link, takes one argument: [7, 7, 5, 5, 5, 1]
                                                            Œɠ - Get the lengths of consecutive elements: [2, 3, 1]
                                                            µ - Call these lengths A
                                                            J - range(length(A)) [1, 2, 3]
                                                            x - Repeat each element by the corresponding value in A: [1, 1, 2, 2, 2, 3]





                                                            share|improve this answer











                                                            $endgroup$














                                                            • $begingroup$
                                                              5 bytes
                                                              $endgroup$
                                                              – Unrelated String
                                                              8 hours ago






                                                            • 1




                                                              $begingroup$
                                                              @UnrelatedString all these new-fangled atoms!
                                                              $endgroup$
                                                              – caird coinheringaahing
                                                              8 hours ago















                                                            1












                                                            $begingroup$


                                                            Jelly, 6 5 bytes



                                                            ŒɠµJx


                                                            Try it online!



                                                            Saved one byte thanks to UnrelatedString!



                                                            Inputs and outputs as array's (with opening/closing brackets)



                                                            How it works



                                                            ŒɠµJx - Main link, takes one argument: [7, 7, 5, 5, 5, 1]
                                                            Œɠ - Get the lengths of consecutive elements: [2, 3, 1]
                                                            µ - Call these lengths A
                                                            J - range(length(A)) [1, 2, 3]
                                                            x - Repeat each element by the corresponding value in A: [1, 1, 2, 2, 2, 3]





                                                            share|improve this answer











                                                            $endgroup$














                                                            • $begingroup$
                                                              5 bytes
                                                              $endgroup$
                                                              – Unrelated String
                                                              8 hours ago






                                                            • 1




                                                              $begingroup$
                                                              @UnrelatedString all these new-fangled atoms!
                                                              $endgroup$
                                                              – caird coinheringaahing
                                                              8 hours ago













                                                            1












                                                            1








                                                            1





                                                            $begingroup$


                                                            Jelly, 6 5 bytes



                                                            ŒɠµJx


                                                            Try it online!



                                                            Saved one byte thanks to UnrelatedString!



                                                            Inputs and outputs as array's (with opening/closing brackets)



                                                            How it works



                                                            ŒɠµJx - Main link, takes one argument: [7, 7, 5, 5, 5, 1]
                                                            Œɠ - Get the lengths of consecutive elements: [2, 3, 1]
                                                            µ - Call these lengths A
                                                            J - range(length(A)) [1, 2, 3]
                                                            x - Repeat each element by the corresponding value in A: [1, 1, 2, 2, 2, 3]





                                                            share|improve this answer











                                                            $endgroup$




                                                            Jelly, 6 5 bytes



                                                            ŒɠµJx


                                                            Try it online!



                                                            Saved one byte thanks to UnrelatedString!



                                                            Inputs and outputs as array's (with opening/closing brackets)



                                                            How it works



                                                            ŒɠµJx - Main link, takes one argument: [7, 7, 5, 5, 5, 1]
                                                            Œɠ - Get the lengths of consecutive elements: [2, 3, 1]
                                                            µ - Call these lengths A
                                                            J - range(length(A)) [1, 2, 3]
                                                            x - Repeat each element by the corresponding value in A: [1, 1, 2, 2, 2, 3]






                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited 8 hours ago

























                                                            answered 8 hours ago









                                                            caird coinheringaahingcaird coinheringaahing

                                                            7,6363 gold badges31 silver badges86 bronze badges




                                                            7,6363 gold badges31 silver badges86 bronze badges














                                                            • $begingroup$
                                                              5 bytes
                                                              $endgroup$
                                                              – Unrelated String
                                                              8 hours ago






                                                            • 1




                                                              $begingroup$
                                                              @UnrelatedString all these new-fangled atoms!
                                                              $endgroup$
                                                              – caird coinheringaahing
                                                              8 hours ago
















                                                            • $begingroup$
                                                              5 bytes
                                                              $endgroup$
                                                              – Unrelated String
                                                              8 hours ago






                                                            • 1




                                                              $begingroup$
                                                              @UnrelatedString all these new-fangled atoms!
                                                              $endgroup$
                                                              – caird coinheringaahing
                                                              8 hours ago















                                                            $begingroup$
                                                            5 bytes
                                                            $endgroup$
                                                            – Unrelated String
                                                            8 hours ago




                                                            $begingroup$
                                                            5 bytes
                                                            $endgroup$
                                                            – Unrelated String
                                                            8 hours ago




                                                            1




                                                            1




                                                            $begingroup$
                                                            @UnrelatedString all these new-fangled atoms!
                                                            $endgroup$
                                                            – caird coinheringaahing
                                                            8 hours ago




                                                            $begingroup$
                                                            @UnrelatedString all these new-fangled atoms!
                                                            $endgroup$
                                                            – caird coinheringaahing
                                                            8 hours ago











                                                            1












                                                            $begingroup$


                                                            Perl 5, 27 bytes





                                                            s/d/$i+=$&!=$l;$l=$&;$i/ge


                                                            Try it online!






                                                            share|improve this answer









                                                            $endgroup$



















                                                              1












                                                              $begingroup$


                                                              Perl 5, 27 bytes





                                                              s/d/$i+=$&!=$l;$l=$&;$i/ge


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$

















                                                                1












                                                                1








                                                                1





                                                                $begingroup$


                                                                Perl 5, 27 bytes





                                                                s/d/$i+=$&!=$l;$l=$&;$i/ge


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$




                                                                Perl 5, 27 bytes





                                                                s/d/$i+=$&!=$l;$l=$&;$i/ge


                                                                Try it online!







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered 7 hours ago









                                                                Kjetil S.Kjetil S.

                                                                7072 silver badges5 bronze badges




                                                                7072 silver badges5 bronze badges
























                                                                    1












                                                                    $begingroup$


                                                                    Octave / MATLAB, 25 bytes





                                                                    @(x)cumsum([1 ~~diff(x)])


                                                                    Try it online!






                                                                    share|improve this answer









                                                                    $endgroup$



















                                                                      1












                                                                      $begingroup$


                                                                      Octave / MATLAB, 25 bytes





                                                                      @(x)cumsum([1 ~~diff(x)])


                                                                      Try it online!






                                                                      share|improve this answer









                                                                      $endgroup$

















                                                                        1












                                                                        1








                                                                        1





                                                                        $begingroup$


                                                                        Octave / MATLAB, 25 bytes





                                                                        @(x)cumsum([1 ~~diff(x)])


                                                                        Try it online!






                                                                        share|improve this answer









                                                                        $endgroup$




                                                                        Octave / MATLAB, 25 bytes





                                                                        @(x)cumsum([1 ~~diff(x)])


                                                                        Try it online!







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered 7 hours ago









                                                                        Luis MendoLuis Mendo

                                                                        77.7k8 gold badges95 silver badges303 bronze badges




                                                                        77.7k8 gold badges95 silver badges303 bronze badges
























                                                                            1












                                                                            $begingroup$


                                                                            Wolfram Language (Mathematica), 29 bytes



                                                                            Join@@(i=1;0#+i++&/@Split@#)&


                                                                            Try it online!






                                                                            share|improve this answer









                                                                            $endgroup$



















                                                                              1












                                                                              $begingroup$


                                                                              Wolfram Language (Mathematica), 29 bytes



                                                                              Join@@(i=1;0#+i++&/@Split@#)&


                                                                              Try it online!






                                                                              share|improve this answer









                                                                              $endgroup$

















                                                                                1












                                                                                1








                                                                                1





                                                                                $begingroup$


                                                                                Wolfram Language (Mathematica), 29 bytes



                                                                                Join@@(i=1;0#+i++&/@Split@#)&


                                                                                Try it online!






                                                                                share|improve this answer









                                                                                $endgroup$




                                                                                Wolfram Language (Mathematica), 29 bytes



                                                                                Join@@(i=1;0#+i++&/@Split@#)&


                                                                                Try it online!







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered 6 hours ago









                                                                                RomanRoman

                                                                                6151 silver badge6 bronze badges




                                                                                6151 silver badge6 bronze badges
























                                                                                    1












                                                                                    $begingroup$


                                                                                    Jelly, 5 bytes



                                                                                    nƝÄŻ‘


                                                                                    Try it online!



                                                                                    I initially aimed for a 4-byter (the same program but without the Ż) but then quickly realized that a 1 had to be prepended every time due to an oversight... Even though there is another 5-byter in Jelly, I'll actually keep this because it uses a different method.



                                                                                    For each pair of neighbouring items of the input list $L$, test if $L_ine L_i+1, forall 1le i<|L|$ and save these results in a list. Then take the cumulative sum of this list and increment them by 1 to match the chunk indexing system. TL;DR. Whenever we encounter different neighbouring items, we increment the chunk index by 1.






                                                                                    share|improve this answer











                                                                                    $endgroup$



















                                                                                      1












                                                                                      $begingroup$


                                                                                      Jelly, 5 bytes



                                                                                      nƝÄŻ‘


                                                                                      Try it online!



                                                                                      I initially aimed for a 4-byter (the same program but without the Ż) but then quickly realized that a 1 had to be prepended every time due to an oversight... Even though there is another 5-byter in Jelly, I'll actually keep this because it uses a different method.



                                                                                      For each pair of neighbouring items of the input list $L$, test if $L_ine L_i+1, forall 1le i<|L|$ and save these results in a list. Then take the cumulative sum of this list and increment them by 1 to match the chunk indexing system. TL;DR. Whenever we encounter different neighbouring items, we increment the chunk index by 1.






                                                                                      share|improve this answer











                                                                                      $endgroup$

















                                                                                        1












                                                                                        1








                                                                                        1





                                                                                        $begingroup$


                                                                                        Jelly, 5 bytes



                                                                                        nƝÄŻ‘


                                                                                        Try it online!



                                                                                        I initially aimed for a 4-byter (the same program but without the Ż) but then quickly realized that a 1 had to be prepended every time due to an oversight... Even though there is another 5-byter in Jelly, I'll actually keep this because it uses a different method.



                                                                                        For each pair of neighbouring items of the input list $L$, test if $L_ine L_i+1, forall 1le i<|L|$ and save these results in a list. Then take the cumulative sum of this list and increment them by 1 to match the chunk indexing system. TL;DR. Whenever we encounter different neighbouring items, we increment the chunk index by 1.






                                                                                        share|improve this answer











                                                                                        $endgroup$




                                                                                        Jelly, 5 bytes



                                                                                        nƝÄŻ‘


                                                                                        Try it online!



                                                                                        I initially aimed for a 4-byter (the same program but without the Ż) but then quickly realized that a 1 had to be prepended every time due to an oversight... Even though there is another 5-byter in Jelly, I'll actually keep this because it uses a different method.



                                                                                        For each pair of neighbouring items of the input list $L$, test if $L_ine L_i+1, forall 1le i<|L|$ and save these results in a list. Then take the cumulative sum of this list and increment them by 1 to match the chunk indexing system. TL;DR. Whenever we encounter different neighbouring items, we increment the chunk index by 1.







                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 6 hours ago

























                                                                                        answered 6 hours ago









                                                                                        Mr. XcoderMr. Xcoder

                                                                                        33.4k7 gold badges62 silver badges204 bronze badges




                                                                                        33.4k7 gold badges62 silver badges204 bronze badges
























                                                                                            1












                                                                                            $begingroup$


                                                                                            Python 3.8 (pre-release), 41 bytes





                                                                                            lambda l,n=0:[n:=n+(l!=(l:=x))for x in l]


                                                                                            Try it online!



                                                                                            Praise the magic walrus := of assignment expressions.





                                                                                            Python 2, 42 bytes





                                                                                            n=0
                                                                                            for x in input():n+=x!=id;id=x;print n


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$














                                                                                            • $begingroup$
                                                                                              Hmm, how long would this be in Pyth?
                                                                                              $endgroup$
                                                                                              – noɥʇʎԀʎzɐɹƆ
                                                                                              5 hours ago















                                                                                            1












                                                                                            $begingroup$


                                                                                            Python 3.8 (pre-release), 41 bytes





                                                                                            lambda l,n=0:[n:=n+(l!=(l:=x))for x in l]


                                                                                            Try it online!



                                                                                            Praise the magic walrus := of assignment expressions.





                                                                                            Python 2, 42 bytes





                                                                                            n=0
                                                                                            for x in input():n+=x!=id;id=x;print n


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$














                                                                                            • $begingroup$
                                                                                              Hmm, how long would this be in Pyth?
                                                                                              $endgroup$
                                                                                              – noɥʇʎԀʎzɐɹƆ
                                                                                              5 hours ago













                                                                                            1












                                                                                            1








                                                                                            1





                                                                                            $begingroup$


                                                                                            Python 3.8 (pre-release), 41 bytes





                                                                                            lambda l,n=0:[n:=n+(l!=(l:=x))for x in l]


                                                                                            Try it online!



                                                                                            Praise the magic walrus := of assignment expressions.





                                                                                            Python 2, 42 bytes





                                                                                            n=0
                                                                                            for x in input():n+=x!=id;id=x;print n


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$




                                                                                            Python 3.8 (pre-release), 41 bytes





                                                                                            lambda l,n=0:[n:=n+(l!=(l:=x))for x in l]


                                                                                            Try it online!



                                                                                            Praise the magic walrus := of assignment expressions.





                                                                                            Python 2, 42 bytes





                                                                                            n=0
                                                                                            for x in input():n+=x!=id;id=x;print n


                                                                                            Try it online!







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered 5 hours ago









                                                                                            xnorxnor

                                                                                            97.8k19 gold badges201 silver badges461 bronze badges




                                                                                            97.8k19 gold badges201 silver badges461 bronze badges














                                                                                            • $begingroup$
                                                                                              Hmm, how long would this be in Pyth?
                                                                                              $endgroup$
                                                                                              – noɥʇʎԀʎzɐɹƆ
                                                                                              5 hours ago
















                                                                                            • $begingroup$
                                                                                              Hmm, how long would this be in Pyth?
                                                                                              $endgroup$
                                                                                              – noɥʇʎԀʎzɐɹƆ
                                                                                              5 hours ago















                                                                                            $begingroup$
                                                                                            Hmm, how long would this be in Pyth?
                                                                                            $endgroup$
                                                                                            – noɥʇʎԀʎzɐɹƆ
                                                                                            5 hours ago




                                                                                            $begingroup$
                                                                                            Hmm, how long would this be in Pyth?
                                                                                            $endgroup$
                                                                                            – noɥʇʎԀʎzɐɹƆ
                                                                                            5 hours ago











                                                                                            1












                                                                                            $begingroup$


                                                                                            Haskell, 40 bytes





                                                                                            f(a:t)=1:map(+sum[1|a/=t!!0])(f t)
                                                                                            f e=e


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$



















                                                                                              1












                                                                                              $begingroup$


                                                                                              Haskell, 40 bytes





                                                                                              f(a:t)=1:map(+sum[1|a/=t!!0])(f t)
                                                                                              f e=e


                                                                                              Try it online!






                                                                                              share|improve this answer









                                                                                              $endgroup$

















                                                                                                1












                                                                                                1








                                                                                                1





                                                                                                $begingroup$


                                                                                                Haskell, 40 bytes





                                                                                                f(a:t)=1:map(+sum[1|a/=t!!0])(f t)
                                                                                                f e=e


                                                                                                Try it online!






                                                                                                share|improve this answer









                                                                                                $endgroup$




                                                                                                Haskell, 40 bytes





                                                                                                f(a:t)=1:map(+sum[1|a/=t!!0])(f t)
                                                                                                f e=e


                                                                                                Try it online!







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered 3 hours ago









                                                                                                xnorxnor

                                                                                                97.8k19 gold badges201 silver badges461 bronze badges




                                                                                                97.8k19 gold badges201 silver badges461 bronze badges
























                                                                                                    0












                                                                                                    $begingroup$


                                                                                                    Japt v2.0a0, 9 bytes



                                                                                                    £T±A¦(A=X


                                                                                                    Try it






                                                                                                    share|improve this answer









                                                                                                    $endgroup$



















                                                                                                      0












                                                                                                      $begingroup$


                                                                                                      Japt v2.0a0, 9 bytes



                                                                                                      £T±A¦(A=X


                                                                                                      Try it






                                                                                                      share|improve this answer









                                                                                                      $endgroup$

















                                                                                                        0












                                                                                                        0








                                                                                                        0





                                                                                                        $begingroup$


                                                                                                        Japt v2.0a0, 9 bytes



                                                                                                        £T±A¦(A=X


                                                                                                        Try it






                                                                                                        share|improve this answer









                                                                                                        $endgroup$




                                                                                                        Japt v2.0a0, 9 bytes



                                                                                                        £T±A¦(A=X


                                                                                                        Try it







                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered 8 hours ago









                                                                                                        Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                                        4,8861 silver badge30 bronze badges




                                                                                                        4,8861 silver badge30 bronze badges
























                                                                                                            0












                                                                                                            $begingroup$


                                                                                                            Add++, 23 bytes



                                                                                                            D,f,@*,BGd€bL$bLRz€¦XBF


                                                                                                            Try it online!



                                                                                                            How it works



                                                                                                            D,f,@*, - Define a function, f, that takes one argument: [7 7 5 5 5 1]
                                                                                                            BG - Group neighbouring elements together: [[[7 7] [5 5 5] [1]]]
                                                                                                            d - Duplicate: [[[7 7] [5 5 5] [1]] [[7 7] [5 5 5] [1]]]
                                                                                                            €bL - Get the length of each: [[[7 7] [5 5 5] [1]] [2 3 1]]
                                                                                                            $bLR - Length, then range of length: [[2 3 1] [1 2 3]]
                                                                                                            z - Zip together: [[2 1] [3 2] [1 3]]
                                                                                                            €¦X - Reduce each by repetition: [[1 1] [2 2 2] [3]]
                                                                                                            BF - Flatten: [1 1 2 2 2 3]
                                                                                                            - Due to the * in the function definition,
                                                                                                            return the whole stack: [1 1 2 2 2 3]





                                                                                                            share|improve this answer









                                                                                                            $endgroup$



















                                                                                                              0












                                                                                                              $begingroup$


                                                                                                              Add++, 23 bytes



                                                                                                              D,f,@*,BGd€bL$bLRz€¦XBF


                                                                                                              Try it online!



                                                                                                              How it works



                                                                                                              D,f,@*, - Define a function, f, that takes one argument: [7 7 5 5 5 1]
                                                                                                              BG - Group neighbouring elements together: [[[7 7] [5 5 5] [1]]]
                                                                                                              d - Duplicate: [[[7 7] [5 5 5] [1]] [[7 7] [5 5 5] [1]]]
                                                                                                              €bL - Get the length of each: [[[7 7] [5 5 5] [1]] [2 3 1]]
                                                                                                              $bLR - Length, then range of length: [[2 3 1] [1 2 3]]
                                                                                                              z - Zip together: [[2 1] [3 2] [1 3]]
                                                                                                              €¦X - Reduce each by repetition: [[1 1] [2 2 2] [3]]
                                                                                                              BF - Flatten: [1 1 2 2 2 3]
                                                                                                              - Due to the * in the function definition,
                                                                                                              return the whole stack: [1 1 2 2 2 3]





                                                                                                              share|improve this answer









                                                                                                              $endgroup$

















                                                                                                                0












                                                                                                                0








                                                                                                                0





                                                                                                                $begingroup$


                                                                                                                Add++, 23 bytes



                                                                                                                D,f,@*,BGd€bL$bLRz€¦XBF


                                                                                                                Try it online!



                                                                                                                How it works



                                                                                                                D,f,@*, - Define a function, f, that takes one argument: [7 7 5 5 5 1]
                                                                                                                BG - Group neighbouring elements together: [[[7 7] [5 5 5] [1]]]
                                                                                                                d - Duplicate: [[[7 7] [5 5 5] [1]] [[7 7] [5 5 5] [1]]]
                                                                                                                €bL - Get the length of each: [[[7 7] [5 5 5] [1]] [2 3 1]]
                                                                                                                $bLR - Length, then range of length: [[2 3 1] [1 2 3]]
                                                                                                                z - Zip together: [[2 1] [3 2] [1 3]]
                                                                                                                €¦X - Reduce each by repetition: [[1 1] [2 2 2] [3]]
                                                                                                                BF - Flatten: [1 1 2 2 2 3]
                                                                                                                - Due to the * in the function definition,
                                                                                                                return the whole stack: [1 1 2 2 2 3]





                                                                                                                share|improve this answer









                                                                                                                $endgroup$




                                                                                                                Add++, 23 bytes



                                                                                                                D,f,@*,BGd€bL$bLRz€¦XBF


                                                                                                                Try it online!



                                                                                                                How it works



                                                                                                                D,f,@*, - Define a function, f, that takes one argument: [7 7 5 5 5 1]
                                                                                                                BG - Group neighbouring elements together: [[[7 7] [5 5 5] [1]]]
                                                                                                                d - Duplicate: [[[7 7] [5 5 5] [1]] [[7 7] [5 5 5] [1]]]
                                                                                                                €bL - Get the length of each: [[[7 7] [5 5 5] [1]] [2 3 1]]
                                                                                                                $bLR - Length, then range of length: [[2 3 1] [1 2 3]]
                                                                                                                z - Zip together: [[2 1] [3 2] [1 3]]
                                                                                                                €¦X - Reduce each by repetition: [[1 1] [2 2 2] [3]]
                                                                                                                BF - Flatten: [1 1 2 2 2 3]
                                                                                                                - Due to the * in the function definition,
                                                                                                                return the whole stack: [1 1 2 2 2 3]






                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered 7 hours ago









                                                                                                                caird coinheringaahingcaird coinheringaahing

                                                                                                                7,6363 gold badges31 silver badges86 bronze badges




                                                                                                                7,6363 gold badges31 silver badges86 bronze badges
























                                                                                                                    0












                                                                                                                    $begingroup$


                                                                                                                    Japt, 8 7 bytes



                                                                                                                    ä¦Ug)åÄ


                                                                                                                    Try it






                                                                                                                    share|improve this answer











                                                                                                                    $endgroup$



















                                                                                                                      0












                                                                                                                      $begingroup$


                                                                                                                      Japt, 8 7 bytes



                                                                                                                      ä¦Ug)åÄ


                                                                                                                      Try it






                                                                                                                      share|improve this answer











                                                                                                                      $endgroup$

















                                                                                                                        0












                                                                                                                        0








                                                                                                                        0





                                                                                                                        $begingroup$


                                                                                                                        Japt, 8 7 bytes



                                                                                                                        ä¦Ug)åÄ


                                                                                                                        Try it






                                                                                                                        share|improve this answer











                                                                                                                        $endgroup$




                                                                                                                        Japt, 8 7 bytes



                                                                                                                        ä¦Ug)åÄ


                                                                                                                        Try it







                                                                                                                        share|improve this answer














                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer








                                                                                                                        edited 7 hours ago

























                                                                                                                        answered 7 hours ago









                                                                                                                        ShaggyShaggy

                                                                                                                        20.9k3 gold badges20 silver badges71 bronze badges




                                                                                                                        20.9k3 gold badges20 silver badges71 bronze badges
























                                                                                                                            0












                                                                                                                            $begingroup$


                                                                                                                            Retina 0.8.2, 34 bytes



                                                                                                                            bd+b(?<=(b(3|(d+))D*)*)
                                                                                                                            $#3


                                                                                                                            Try it online! Explanation:



                                                                                                                            bd+b


                                                                                                                            Match each number in turn.



                                                                                                                            (?<=(...)*)


                                                                                                                            Start looking backwards for as many matches as possible. (The next entries will be in right-to-left order as that's how lookbehind works.)



                                                                                                                            D*


                                                                                                                            Skip the separators.



                                                                                                                            (3|(d+))


                                                                                                                            Try to match the same number as last time, but failing that, just match any number, but remember that we had to match a new number.



                                                                                                                            b


                                                                                                                            Ensure the whole number is matched.



                                                                                                                            $#3


                                                                                                                            Count the number of new numbers.






                                                                                                                            share|improve this answer









                                                                                                                            $endgroup$



















                                                                                                                              0












                                                                                                                              $begingroup$


                                                                                                                              Retina 0.8.2, 34 bytes



                                                                                                                              bd+b(?<=(b(3|(d+))D*)*)
                                                                                                                              $#3


                                                                                                                              Try it online! Explanation:



                                                                                                                              bd+b


                                                                                                                              Match each number in turn.



                                                                                                                              (?<=(...)*)


                                                                                                                              Start looking backwards for as many matches as possible. (The next entries will be in right-to-left order as that's how lookbehind works.)



                                                                                                                              D*


                                                                                                                              Skip the separators.



                                                                                                                              (3|(d+))


                                                                                                                              Try to match the same number as last time, but failing that, just match any number, but remember that we had to match a new number.



                                                                                                                              b


                                                                                                                              Ensure the whole number is matched.



                                                                                                                              $#3


                                                                                                                              Count the number of new numbers.






                                                                                                                              share|improve this answer









                                                                                                                              $endgroup$

















                                                                                                                                0












                                                                                                                                0








                                                                                                                                0





                                                                                                                                $begingroup$


                                                                                                                                Retina 0.8.2, 34 bytes



                                                                                                                                bd+b(?<=(b(3|(d+))D*)*)
                                                                                                                                $#3


                                                                                                                                Try it online! Explanation:



                                                                                                                                bd+b


                                                                                                                                Match each number in turn.



                                                                                                                                (?<=(...)*)


                                                                                                                                Start looking backwards for as many matches as possible. (The next entries will be in right-to-left order as that's how lookbehind works.)



                                                                                                                                D*


                                                                                                                                Skip the separators.



                                                                                                                                (3|(d+))


                                                                                                                                Try to match the same number as last time, but failing that, just match any number, but remember that we had to match a new number.



                                                                                                                                b


                                                                                                                                Ensure the whole number is matched.



                                                                                                                                $#3


                                                                                                                                Count the number of new numbers.






                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$




                                                                                                                                Retina 0.8.2, 34 bytes



                                                                                                                                bd+b(?<=(b(3|(d+))D*)*)
                                                                                                                                $#3


                                                                                                                                Try it online! Explanation:



                                                                                                                                bd+b


                                                                                                                                Match each number in turn.



                                                                                                                                (?<=(...)*)


                                                                                                                                Start looking backwards for as many matches as possible. (The next entries will be in right-to-left order as that's how lookbehind works.)



                                                                                                                                D*


                                                                                                                                Skip the separators.



                                                                                                                                (3|(d+))


                                                                                                                                Try to match the same number as last time, but failing that, just match any number, but remember that we had to match a new number.



                                                                                                                                b


                                                                                                                                Ensure the whole number is matched.



                                                                                                                                $#3


                                                                                                                                Count the number of new numbers.







                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered 6 hours ago









                                                                                                                                NeilNeil

                                                                                                                                87.1k8 gold badges46 silver badges183 bronze badges




                                                                                                                                87.1k8 gold badges46 silver badges183 bronze badges
























                                                                                                                                    0












                                                                                                                                    $begingroup$


                                                                                                                                    05AB1E, 5 bytes



                                                                                                                                    ¥Ā.¥>


                                                                                                                                    Try it online!






                                                                                                                                    share|improve this answer









                                                                                                                                    $endgroup$



















                                                                                                                                      0












                                                                                                                                      $begingroup$


                                                                                                                                      05AB1E, 5 bytes



                                                                                                                                      ¥Ā.¥>


                                                                                                                                      Try it online!






                                                                                                                                      share|improve this answer









                                                                                                                                      $endgroup$

















                                                                                                                                        0












                                                                                                                                        0








                                                                                                                                        0





                                                                                                                                        $begingroup$


                                                                                                                                        05AB1E, 5 bytes



                                                                                                                                        ¥Ā.¥>


                                                                                                                                        Try it online!






                                                                                                                                        share|improve this answer









                                                                                                                                        $endgroup$




                                                                                                                                        05AB1E, 5 bytes



                                                                                                                                        ¥Ā.¥>


                                                                                                                                        Try it online!







                                                                                                                                        share|improve this answer












                                                                                                                                        share|improve this answer



                                                                                                                                        share|improve this answer










                                                                                                                                        answered 6 hours ago









                                                                                                                                        Mr. XcoderMr. Xcoder

                                                                                                                                        33.4k7 gold badges62 silver badges204 bronze badges




                                                                                                                                        33.4k7 gold badges62 silver badges204 bronze badges
























                                                                                                                                            0












                                                                                                                                            $begingroup$


                                                                                                                                            Stax, 10 bytes



                                                                                                                                            ▓ª2ªmD?Ä╧╖


                                                                                                                                            Run and debug it



                                                                                                                                            The output uses space as a delimiter. The input follows the precise specifications using commas as separators, and now enclosing braces.






                                                                                                                                            share|improve this answer











                                                                                                                                            $endgroup$



















                                                                                                                                              0












                                                                                                                                              $begingroup$


                                                                                                                                              Stax, 10 bytes



                                                                                                                                              ▓ª2ªmD?Ä╧╖


                                                                                                                                              Run and debug it



                                                                                                                                              The output uses space as a delimiter. The input follows the precise specifications using commas as separators, and now enclosing braces.






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$

















                                                                                                                                                0












                                                                                                                                                0








                                                                                                                                                0





                                                                                                                                                $begingroup$


                                                                                                                                                Stax, 10 bytes



                                                                                                                                                ▓ª2ªmD?Ä╧╖


                                                                                                                                                Run and debug it



                                                                                                                                                The output uses space as a delimiter. The input follows the precise specifications using commas as separators, and now enclosing braces.






                                                                                                                                                share|improve this answer











                                                                                                                                                $endgroup$




                                                                                                                                                Stax, 10 bytes



                                                                                                                                                ▓ª2ªmD?Ä╧╖


                                                                                                                                                Run and debug it



                                                                                                                                                The output uses space as a delimiter. The input follows the precise specifications using commas as separators, and now enclosing braces.







                                                                                                                                                share|improve this answer














                                                                                                                                                share|improve this answer



                                                                                                                                                share|improve this answer








                                                                                                                                                edited 5 hours ago

























                                                                                                                                                answered 8 hours ago









                                                                                                                                                recursiverecursive

                                                                                                                                                7,77115 silver badges30 bronze badges




                                                                                                                                                7,77115 silver badges30 bronze badges
























                                                                                                                                                    0












                                                                                                                                                    $begingroup$


                                                                                                                                                    C (gcc), 62 61 bytes



                                                                                                                                                    This is one of the few entries I've done where a complete program is shorter than a function submission!



                                                                                                                                                    On the first pass, I don't care about the previous value, so I get to rely on the fact that argv is a pointer to somewhere and is extremely unlikely to be between [0..9]!





                                                                                                                                                    s;main(i,j)for(;~scanf("%d,",&i);j=i)printf("%d ",s+=j!=i);


                                                                                                                                                    Try it online!






                                                                                                                                                    share|improve this answer











                                                                                                                                                    $endgroup$



















                                                                                                                                                      0












                                                                                                                                                      $begingroup$


                                                                                                                                                      C (gcc), 62 61 bytes



                                                                                                                                                      This is one of the few entries I've done where a complete program is shorter than a function submission!



                                                                                                                                                      On the first pass, I don't care about the previous value, so I get to rely on the fact that argv is a pointer to somewhere and is extremely unlikely to be between [0..9]!





                                                                                                                                                      s;main(i,j)for(;~scanf("%d,",&i);j=i)printf("%d ",s+=j!=i);


                                                                                                                                                      Try it online!






                                                                                                                                                      share|improve this answer











                                                                                                                                                      $endgroup$

















                                                                                                                                                        0












                                                                                                                                                        0








                                                                                                                                                        0





                                                                                                                                                        $begingroup$


                                                                                                                                                        C (gcc), 62 61 bytes



                                                                                                                                                        This is one of the few entries I've done where a complete program is shorter than a function submission!



                                                                                                                                                        On the first pass, I don't care about the previous value, so I get to rely on the fact that argv is a pointer to somewhere and is extremely unlikely to be between [0..9]!





                                                                                                                                                        s;main(i,j)for(;~scanf("%d,",&i);j=i)printf("%d ",s+=j!=i);


                                                                                                                                                        Try it online!






                                                                                                                                                        share|improve this answer











                                                                                                                                                        $endgroup$




                                                                                                                                                        C (gcc), 62 61 bytes



                                                                                                                                                        This is one of the few entries I've done where a complete program is shorter than a function submission!



                                                                                                                                                        On the first pass, I don't care about the previous value, so I get to rely on the fact that argv is a pointer to somewhere and is extremely unlikely to be between [0..9]!





                                                                                                                                                        s;main(i,j)for(;~scanf("%d,",&i);j=i)printf("%d ",s+=j!=i);


                                                                                                                                                        Try it online!







                                                                                                                                                        share|improve this answer














                                                                                                                                                        share|improve this answer



                                                                                                                                                        share|improve this answer








                                                                                                                                                        edited 2 hours ago

























                                                                                                                                                        answered 2 hours ago









                                                                                                                                                        ErikFErikF

                                                                                                                                                        1,6192 silver badges7 bronze badges




                                                                                                                                                        1,6192 silver badges7 bronze badges
























                                                                                                                                                            0












                                                                                                                                                            $begingroup$


                                                                                                                                                            Perl 6, 21 bytes





                                                                                                                                                            +<<[+] $,


                                                                                                                                                            Try it online!



                                                                                                                                                            Anonymous code block that takes a list and returns a list. This works by comparing whether each pair of adjacent elements are not equal, than taking the cumulative sum of the list.






                                                                                                                                                            share|improve this answer









                                                                                                                                                            $endgroup$



















                                                                                                                                                              0












                                                                                                                                                              $begingroup$


                                                                                                                                                              Perl 6, 21 bytes





                                                                                                                                                              +<<[+] $,


                                                                                                                                                              Try it online!



                                                                                                                                                              Anonymous code block that takes a list and returns a list. This works by comparing whether each pair of adjacent elements are not equal, than taking the cumulative sum of the list.






                                                                                                                                                              share|improve this answer









                                                                                                                                                              $endgroup$

















                                                                                                                                                                0












                                                                                                                                                                0








                                                                                                                                                                0





                                                                                                                                                                $begingroup$


                                                                                                                                                                Perl 6, 21 bytes





                                                                                                                                                                +<<[+] $,


                                                                                                                                                                Try it online!



                                                                                                                                                                Anonymous code block that takes a list and returns a list. This works by comparing whether each pair of adjacent elements are not equal, than taking the cumulative sum of the list.






                                                                                                                                                                share|improve this answer









                                                                                                                                                                $endgroup$




                                                                                                                                                                Perl 6, 21 bytes





                                                                                                                                                                +<<[+] $,


                                                                                                                                                                Try it online!



                                                                                                                                                                Anonymous code block that takes a list and returns a list. This works by comparing whether each pair of adjacent elements are not equal, than taking the cumulative sum of the list.







                                                                                                                                                                share|improve this answer












                                                                                                                                                                share|improve this answer



                                                                                                                                                                share|improve this answer










                                                                                                                                                                answered 1 hour ago









                                                                                                                                                                Jo KingJo King

                                                                                                                                                                30.6k3 gold badges71 silver badges138 bronze badges




                                                                                                                                                                30.6k3 gold badges71 silver badges138 bronze badges
























                                                                                                                                                                    0












                                                                                                                                                                    $begingroup$


                                                                                                                                                                    Haskell, 46 43 bytes





                                                                                                                                                                    scanl(+)1.map fromEnum.(zipWith(/=)=<<tail)


                                                                                                                                                                    Try it online!



                                                                                                                                                                    Anonymous pointfree function that takes a list and returns a list






                                                                                                                                                                    share|improve this answer











                                                                                                                                                                    $endgroup$



















                                                                                                                                                                      0












                                                                                                                                                                      $begingroup$


                                                                                                                                                                      Haskell, 46 43 bytes





                                                                                                                                                                      scanl(+)1.map fromEnum.(zipWith(/=)=<<tail)


                                                                                                                                                                      Try it online!



                                                                                                                                                                      Anonymous pointfree function that takes a list and returns a list






                                                                                                                                                                      share|improve this answer











                                                                                                                                                                      $endgroup$

















                                                                                                                                                                        0












                                                                                                                                                                        0








                                                                                                                                                                        0





                                                                                                                                                                        $begingroup$


                                                                                                                                                                        Haskell, 46 43 bytes





                                                                                                                                                                        scanl(+)1.map fromEnum.(zipWith(/=)=<<tail)


                                                                                                                                                                        Try it online!



                                                                                                                                                                        Anonymous pointfree function that takes a list and returns a list






                                                                                                                                                                        share|improve this answer











                                                                                                                                                                        $endgroup$




                                                                                                                                                                        Haskell, 46 43 bytes





                                                                                                                                                                        scanl(+)1.map fromEnum.(zipWith(/=)=<<tail)


                                                                                                                                                                        Try it online!



                                                                                                                                                                        Anonymous pointfree function that takes a list and returns a list







                                                                                                                                                                        share|improve this answer














                                                                                                                                                                        share|improve this answer



                                                                                                                                                                        share|improve this answer








                                                                                                                                                                        edited 1 hour ago

























                                                                                                                                                                        answered 4 hours ago









                                                                                                                                                                        Jo KingJo King

                                                                                                                                                                        30.6k3 gold badges71 silver badges138 bronze badges




                                                                                                                                                                        30.6k3 gold badges71 silver badges138 bronze badges






























                                                                                                                                                                            draft saved

                                                                                                                                                                            draft discarded
















































                                                                                                                                                                            If this is an answer to a challenge…



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


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


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


                                                                                                                                                                            More generally…



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


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




                                                                                                                                                                            draft saved


                                                                                                                                                                            draft discarded














                                                                                                                                                                            StackExchange.ready(
                                                                                                                                                                            function ()
                                                                                                                                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f189932%2fchunk-enumerate-a-list-of-digits%23new-answer', 'question_page');

                                                                                                                                                                            );

                                                                                                                                                                            Post as a guest















                                                                                                                                                                            Required, but never shown





















































                                                                                                                                                                            Required, but never shown














                                                                                                                                                                            Required, but never shown












                                                                                                                                                                            Required, but never shown







                                                                                                                                                                            Required, but never shown

































                                                                                                                                                                            Required, but never shown














                                                                                                                                                                            Required, but never shown












                                                                                                                                                                            Required, but never shown







                                                                                                                                                                            Required, but never shown







                                                                                                                                                                            Popular posts from this blog

                                                                                                                                                                            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                                                                                                                                                            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                                                                                                                                                            Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її