Incremental Ranges!Analyzing Collatz-like sequencesFinding Collatz-like rules with many loopsGenerate The SUDSI SequenceThe Kimberling SequenceHow many integers contain a number in a specific rangeCompress a maximal discrepancy-2 sequenceA Euro-iginal SequenceThe Ever-Increasing GraphThe Jumping Up SequenceA function to take three integers and return a list of integers and alphabet-letters

Did Darth Vader wear the same suit for 20+ years?

Asking bank to reduce APR instead of increasing credit limit

Why was it possible to cause an Apple //e to shut down with SHIFT and paddle button 2?

Why does a helium balloon rise?

Comma Code - Ch. 4 Automate the Boring Stuff

What is the best option to connect old computer to modern TV

Will dual-learning in a glider make my airplane learning safer?

Explain Ant-Man's "not it" scene from Avengers: Endgame

Can The Malloreon be read without first reading The Belgariad?

Should we freeze the number of people coming in to the study for Kaplan-Meier test

Short story written from alien perspective with this line: "It's too bright to look at, so they don't"

Rotated Position of Integers

PhD student with mental health issues and bad performance

Incremental Ranges!

Strange math syntax in old basic listing

How can I add depth to my story or how do I determine if my story already has depth?

What happens if you do emergency landing on a US base in middle of the ocean?

What does War Machine's "Canopy! Canopy!" line mean in "Avengers: Endgame"?

Computing the differentials in the Adams spectral sequence

What's the most polite way to tell a manager "shut up and let me work"?

How can Iron Man's suit withstand this?

What is the correct expression of 10/20, 20/30, 30/40 etc?

Accidentally cashed a check twice

What is the right way to float a home lab?



Incremental Ranges!


Analyzing Collatz-like sequencesFinding Collatz-like rules with many loopsGenerate The SUDSI SequenceThe Kimberling SequenceHow many integers contain a number in a specific rangeCompress a maximal discrepancy-2 sequenceA Euro-iginal SequenceThe Ever-Increasing GraphThe Jumping Up SequenceA function to take three integers and return a list of integers and alphabet-letters













8












$begingroup$


Your task is to, given two positive integers, $x$ and $n$, return the first $x$ numbers in the incremental ranges sequence.



The incremental range sequence first generates a range from one to $n$ inclusive. For example, if $n$ was $3$, it would generate the list $[1,2,3]$. It then repeatedly appends the last $n$ values incremented by $1$ to the existing list, and continues.



An input of $n=3$ for example:



n=3
1. Get range 1 to n. List: [1,2,3]
2. Get the last n values of the list. List: [1,2,3]. Last n=3 values: [1,2,3].
3. Increment the last n values by 1. List: [1,2,3]. Last n values: [2,3,4].
4. Append the last n values incremented to the list. List: [1,2,3,2,3,4]
5. Repeat steps 2-5. 2nd time repeat shown below.

2nd repeat:
2. Get the last n values of the list. List: [1,2,3,2,3,4]. Last n=3 values: [2,3,4]
3. Increment the last n values by 1. List: [1,2,3,2,3,4]. Last n values: [3,4,5].
4. Append the last n values incremented to the list. List: [1,2,3,2,3,4,3,4,5]


Test cases:



n, x, Output
1, 49, [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]
2, 100, [1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51]
3, 13, [1,2,3,2,3,4,3,4,5,4,5,6,5]









share|improve this question











$endgroup$
















    8












    $begingroup$


    Your task is to, given two positive integers, $x$ and $n$, return the first $x$ numbers in the incremental ranges sequence.



    The incremental range sequence first generates a range from one to $n$ inclusive. For example, if $n$ was $3$, it would generate the list $[1,2,3]$. It then repeatedly appends the last $n$ values incremented by $1$ to the existing list, and continues.



    An input of $n=3$ for example:



    n=3
    1. Get range 1 to n. List: [1,2,3]
    2. Get the last n values of the list. List: [1,2,3]. Last n=3 values: [1,2,3].
    3. Increment the last n values by 1. List: [1,2,3]. Last n values: [2,3,4].
    4. Append the last n values incremented to the list. List: [1,2,3,2,3,4]
    5. Repeat steps 2-5. 2nd time repeat shown below.

    2nd repeat:
    2. Get the last n values of the list. List: [1,2,3,2,3,4]. Last n=3 values: [2,3,4]
    3. Increment the last n values by 1. List: [1,2,3,2,3,4]. Last n values: [3,4,5].
    4. Append the last n values incremented to the list. List: [1,2,3,2,3,4,3,4,5]


    Test cases:



    n, x, Output
    1, 49, [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]
    2, 100, [1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51]
    3, 13, [1,2,3,2,3,4,3,4,5,4,5,6,5]









    share|improve this question











    $endgroup$














      8












      8








      8





      $begingroup$


      Your task is to, given two positive integers, $x$ and $n$, return the first $x$ numbers in the incremental ranges sequence.



      The incremental range sequence first generates a range from one to $n$ inclusive. For example, if $n$ was $3$, it would generate the list $[1,2,3]$. It then repeatedly appends the last $n$ values incremented by $1$ to the existing list, and continues.



      An input of $n=3$ for example:



      n=3
      1. Get range 1 to n. List: [1,2,3]
      2. Get the last n values of the list. List: [1,2,3]. Last n=3 values: [1,2,3].
      3. Increment the last n values by 1. List: [1,2,3]. Last n values: [2,3,4].
      4. Append the last n values incremented to the list. List: [1,2,3,2,3,4]
      5. Repeat steps 2-5. 2nd time repeat shown below.

      2nd repeat:
      2. Get the last n values of the list. List: [1,2,3,2,3,4]. Last n=3 values: [2,3,4]
      3. Increment the last n values by 1. List: [1,2,3,2,3,4]. Last n values: [3,4,5].
      4. Append the last n values incremented to the list. List: [1,2,3,2,3,4,3,4,5]


      Test cases:



      n, x, Output
      1, 49, [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]
      2, 100, [1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51]
      3, 13, [1,2,3,2,3,4,3,4,5,4,5,6,5]









      share|improve this question











      $endgroup$




      Your task is to, given two positive integers, $x$ and $n$, return the first $x$ numbers in the incremental ranges sequence.



      The incremental range sequence first generates a range from one to $n$ inclusive. For example, if $n$ was $3$, it would generate the list $[1,2,3]$. It then repeatedly appends the last $n$ values incremented by $1$ to the existing list, and continues.



      An input of $n=3$ for example:



      n=3
      1. Get range 1 to n. List: [1,2,3]
      2. Get the last n values of the list. List: [1,2,3]. Last n=3 values: [1,2,3].
      3. Increment the last n values by 1. List: [1,2,3]. Last n values: [2,3,4].
      4. Append the last n values incremented to the list. List: [1,2,3,2,3,4]
      5. Repeat steps 2-5. 2nd time repeat shown below.

      2nd repeat:
      2. Get the last n values of the list. List: [1,2,3,2,3,4]. Last n=3 values: [2,3,4]
      3. Increment the last n values by 1. List: [1,2,3,2,3,4]. Last n values: [3,4,5].
      4. Append the last n values incremented to the list. List: [1,2,3,2,3,4,3,4,5]


      Test cases:



      n, x, Output
      1, 49, [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]
      2, 100, [1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51]
      3, 13, [1,2,3,2,3,4,3,4,5,4,5,6,5]






      code-golf number sequence array






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 hours ago









      Giuseppe

      18.6k31358




      18.6k31358










      asked 9 hours ago









      Comrade SparklePonyComrade SparklePony

      3,70611756




      3,70611756




















          21 Answers
          21






          active

          oldest

          votes


















          4












          $begingroup$


          Python 2, 39 bytes





          lambda n,x:[v/n+v%n+1for v in range(x)]


          Try it online!






          share|improve this answer









          $endgroup$












          • $begingroup$
            Also works in Python 3 with the replacement of / with //
            $endgroup$
            – Nick Kennedy
            7 hours ago


















          3












          $begingroup$


          Jelly, 4 bytes



          Ḷd§‘


          A dyadic Link accepting two positive integers, x on the left and n on the right, which yields a list of positive integers.



          Try it online!



          How?



          Ḷd§‘ - Link: x, n e.g 13, 3
          Ḷ - lowered range (x) [0,1,2,3,4,5,6,7,8,9,10,11,12]
          d - divmod (n) [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
          § - sums [0,1,2,1,2,3,2,3,4,3,4,5,4]
          ‘ - increment (vectorises) [1,2,3,2,3,4,3,4,5,4,5,6,5]





          share|improve this answer











          $endgroup$








          • 2




            $begingroup$
            Wait... is that divmod? Clever! And I was struggling with p...
            $endgroup$
            – Erik the Outgolfer
            8 hours ago



















          3












          $begingroup$


          R, 33 bytes





          function(n,x,z=1:x-1)z%%n+z%/%n+1


          Try it online!



          Ports Jonathan Allan's Python solution.




          R, 36 bytes





          function(n,x)outer(1:n,0:x,"+")[1:x]


          Try it online!



          My original solution; generates an $ntimes x$ matrix with each column as the increments, i.e., $1 ldots n, 2ldots n+1,ldots$, then takes the first $x$ entries (going down the columns).






          share|improve this answer











          $endgroup$




















            2












            $begingroup$


            05AB1E, 6 bytes



            L<s‰O>


            Port of @JonathanAllan's Jelly answer, so make sure to upvote him!



            First input is $x$, second input is $n$.



            Try it online or verify all test cases.



            Explanation:





            L # Push a list in the range [1, (implicit) input]
            # i.e. 13 → [1,2,3,4,5,6,7,8,9,10,11,12,13]
            < # Decrease each by 1 to the range [0, input)
            # → [0,1,2,3,4,5,6,7,8,9,10,11,12]
            s‰ # Divmod each by the second input
            # i.e. 3 → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
            O # Sum each pair
            # → [0,1,2,1,2,3,2,3,4,3,4,5,4]
            > # And increase each by 1
            # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
            # (after which the result is output implicitly)





            My own initial approach was 8 bytes:



            LI∍εN¹÷+


            First input is $n$, second input is $x$.



            Try it online or verify all test cases.



            Explanation:





            L # Push a list in the range [1, (implicit) input]
            # i.e. 3 → [1,2,3]
            I∍ # Extend it to the size of the second input
            # i.e. 13 → [1,2,3,1,2,3,1,2,3,1,2,3,1]
            ε # Map each value to:
            N¹÷ # The 0-based index integer-divided by the first input
            # → [0,0,0,1,1,1,2,2,2,3,3,3,4]
            + # Add that to the value
            # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
            # (after which the result is output implicitly)





            share|improve this answer









            $endgroup$




















              2












              $begingroup$


              Brain-Flak, 100 bytes



              (<>)<>([()]<(())(()[()](<>))<>(()<>)(<>)(<>)([()]<(<>[](())[()]<>)>)>)


              With comments and formatting:



              # Push a zero under the other stack
              (<>)<>

              # x times

              # x - 1
              ([()]<

              # Let 'a' be a counter that starts at n
              # Duplicate a and NOT
              (())(()[()](<>))

              # if a == 0

              # Pop truthy

              <>

              # Reset n to a
              (()<>)

              # Push 0 to each
              (<>)(<>)


              # Pop falsy


              # Decrement A, add one to the other stack, and duplicate that number under this stack
              ([()]<
              (<>[](())<>)
              >)
              >)



              Try it online!






              share|improve this answer











              $endgroup$












              • $begingroup$
                Your "golfed" version doesn't work (and the formatted/commented version on TIO minifies to 100 bytes).
                $endgroup$
                – Nitrodon
                4 hours ago











              • $begingroup$
                @Nitrodon Whoops, not sure how that happened. Fixed now!
                $endgroup$
                – DJMcMayhem
                4 hours ago


















              1












              $begingroup$


              Jelly, 5 bytes



              +þẎḣ’


              Try it online!






              share|improve this answer









              $endgroup$




















                1












                $begingroup$


                Ruby, 32 bytes





                ->n,x(0...x).map


                Try it online!






                share|improve this answer









                $endgroup$




















                  1












                  $begingroup$


                  Japt -m, 12 7 bytes



                  Port of Jonathan's Python solution.



                  Takes x as the first input.



                  %VÄ+UzV


                  Try it






                  share|improve this answer











                  $endgroup$




















                    1












                    $begingroup$


                    Perl 6, 18 bytes





                    (1..*X+ ^*)[^$_]


                    Try it online!



                    Curried function f(x)(n).



                    Explanation



                     # Anonymous block
                    X+ # Cartesian product with addition
                    1..* # of range 1..Inf
                    ^* # and range 0..n
                    ( )[^$_] # First x elements





                    share|improve this answer











                    $endgroup$




















                      1












                      $begingroup$


                      Perl 5 -na, 43 bytes





                      @r=map$_..$_+$F[1]-1,1..$_;say"@r[0..$_-1]"


                      Try it online!






                      share|improve this answer









                      $endgroup$




















                        1












                        $begingroup$


                        Octave, 25 bytes





                        @(n,x)((1:n)'+(0:x))(1:x)


                        Anonymous function that inputs numbers n``andx`, and outputs a row vector.



                        Try it online!






                        share|improve this answer









                        $endgroup$




















                          1












                          $begingroup$


                          MATL, 16 bytes



                          :i:"tQ]v!1e 2G:)


                          Try it online!



                          Explanation:



                          : % Push [1, 2... n]
                          i:" ] % For i in [1, x]:
                          t % Duplicate the first array
                          Q % Increment each number
                          v % Concatenate everything into 1 matrix
                          ! % Transpose
                          1e % Reshape into 1 row
                          2G % Push x again
                          :) % And take the first x elements





                          share|improve this answer









                          $endgroup$








                          • 1




                            $begingroup$
                            10 bytes using broadcasting.
                            $endgroup$
                            – Giuseppe
                            3 hours ago


















                          1












                          $begingroup$


                          J, 13 12 bytes



                          [$[:,1++/&i.


                          Try it online!



                          how



                          We take x as the left arg, n as the right. Let's take x = 8 and n = 3 for this example:




                          • +/&i.: Transform both args by creating integer ranges i., that is, the left arg becomes 0 1 2 3 4 5 6 7 and the right arg becomes 0 1 2. Now we create an "addition table +/ from those two:



                             0 1 2
                            1 2 3
                            2 3 4
                            3 4 5
                            4 5 6
                            5 6 7
                            6 7 8
                            7 8 9



                          • 1 +: Add 1 to every element of this table:



                             1 2 3
                            2 3 4
                            3 4 5
                            4 5 6
                            5 6 7
                            6 7 8
                            7 8 9
                            8 9 10



                          • [: ,: Flatten it ,:



                             1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10



                          • [ $: Shape it $ so it has the same number of elements as the original, untransformed left arg [, ie, x:



                             1 2 3 2 3 4 3 4 






                          share|improve this answer











                          $endgroup$




















                            0












                            $begingroup$


                            Alchemist, 77 bytes



                            _->In_n+In_x
                            x+n+0y+0z->a+Out_a+Out_" "+m+y
                            y+n->n
                            y+0n->z
                            z+m+a->z+n
                            z+0m->a


                            Try it online!



                            Increments and outputs a counter n times, then subtracts n-1 before repeating.






                            share|improve this answer









                            $endgroup$




















                              0












                              $begingroup$


                              Charcoal, 18 bytes



                              NθFN⊞υ⊕⎇‹ιθι§υ±θIυ


                              Try it online! Link is to verbose version of code. I had dreams of seeding the list with a zero-indexed range and then slicing it off again but that was actually 2 bytes longer. Explanation:



                              Nθ Input `n` into variable
                              N Input `x`
                              F Loop over implicit range
                              ι Current index
                              ‹ Less than
                              θ Variable `n`
                              ⎇ ι Then current index else
                              θ Variable `n`
                              ± Negated
                              §υ Cyclically indexed into list
                              ⊕ Incremented
                              ⊞υ Pushed to list
                              Iυ Cast list to string for implicit output





                              share|improve this answer









                              $endgroup$




















                                0












                                $begingroup$

                                APL+WIN, 29 23 bytes



                                x↑,(0,⍳⌊(x←⎕)÷n)∘.+⍳n←⎕


                                Prompts for n and x



                                Try it online! Courtesy of Dyalog Classic






                                share|improve this answer











                                $endgroup$




















                                  0












                                  $begingroup$

                                  JS, 54 bytes



                                  f=(n,x)=>Array.from(Array(x),(_,i)=>i+1-(i/n|0)*(n-1))


                                  Try it online!






                                  share|improve this answer








                                  New contributor



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





                                  $endgroup$




















                                    0












                                    $begingroup$

                                    Haskell, 34 33 bytes



                                    n#x=take x$do j<-[1..];[j..j+n-1]


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$




















                                      0












                                      $begingroup$

                                      JavaScript, 36 bytes



                                      n=>g=x=>x?[...g(--x),1+x%n+x/n|0]:[]


                                      Try It Online!






                                      share|improve this answer











                                      $endgroup$




















                                        0












                                        $begingroup$


                                        C (gcc), 49 bytes





                                        f(n,x,i)for(i=0;x--;)printf("%d ",i%n+i++/n+1);


                                        Try it online!






                                        share|improve this answer









                                        $endgroup$




















                                          0












                                          $begingroup$


                                          Perl 5, 39 bytes





                                          say 1+int($_/$F[1])+$_%$F[1]for 0..$_-1


                                          Try it online!






                                          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%2f186233%2fincremental-ranges%23new-answer', 'question_page');

                                            );

                                            Post as a guest















                                            Required, but never shown

























                                            21 Answers
                                            21






                                            active

                                            oldest

                                            votes








                                            21 Answers
                                            21






                                            active

                                            oldest

                                            votes









                                            active

                                            oldest

                                            votes






                                            active

                                            oldest

                                            votes









                                            4












                                            $begingroup$


                                            Python 2, 39 bytes





                                            lambda n,x:[v/n+v%n+1for v in range(x)]


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$












                                            • $begingroup$
                                              Also works in Python 3 with the replacement of / with //
                                              $endgroup$
                                              – Nick Kennedy
                                              7 hours ago















                                            4












                                            $begingroup$


                                            Python 2, 39 bytes





                                            lambda n,x:[v/n+v%n+1for v in range(x)]


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$












                                            • $begingroup$
                                              Also works in Python 3 with the replacement of / with //
                                              $endgroup$
                                              – Nick Kennedy
                                              7 hours ago













                                            4












                                            4








                                            4





                                            $begingroup$


                                            Python 2, 39 bytes





                                            lambda n,x:[v/n+v%n+1for v in range(x)]


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$




                                            Python 2, 39 bytes





                                            lambda n,x:[v/n+v%n+1for v in range(x)]


                                            Try it online!







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered 8 hours ago









                                            Jonathan AllanJonathan Allan

                                            56k538178




                                            56k538178











                                            • $begingroup$
                                              Also works in Python 3 with the replacement of / with //
                                              $endgroup$
                                              – Nick Kennedy
                                              7 hours ago
















                                            • $begingroup$
                                              Also works in Python 3 with the replacement of / with //
                                              $endgroup$
                                              – Nick Kennedy
                                              7 hours ago















                                            $begingroup$
                                            Also works in Python 3 with the replacement of / with //
                                            $endgroup$
                                            – Nick Kennedy
                                            7 hours ago




                                            $begingroup$
                                            Also works in Python 3 with the replacement of / with //
                                            $endgroup$
                                            – Nick Kennedy
                                            7 hours ago











                                            3












                                            $begingroup$


                                            Jelly, 4 bytes



                                            Ḷd§‘


                                            A dyadic Link accepting two positive integers, x on the left and n on the right, which yields a list of positive integers.



                                            Try it online!



                                            How?



                                            Ḷd§‘ - Link: x, n e.g 13, 3
                                            Ḷ - lowered range (x) [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                            d - divmod (n) [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                            § - sums [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                            ‘ - increment (vectorises) [1,2,3,2,3,4,3,4,5,4,5,6,5]





                                            share|improve this answer











                                            $endgroup$








                                            • 2




                                              $begingroup$
                                              Wait... is that divmod? Clever! And I was struggling with p...
                                              $endgroup$
                                              – Erik the Outgolfer
                                              8 hours ago
















                                            3












                                            $begingroup$


                                            Jelly, 4 bytes



                                            Ḷd§‘


                                            A dyadic Link accepting two positive integers, x on the left and n on the right, which yields a list of positive integers.



                                            Try it online!



                                            How?



                                            Ḷd§‘ - Link: x, n e.g 13, 3
                                            Ḷ - lowered range (x) [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                            d - divmod (n) [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                            § - sums [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                            ‘ - increment (vectorises) [1,2,3,2,3,4,3,4,5,4,5,6,5]





                                            share|improve this answer











                                            $endgroup$








                                            • 2




                                              $begingroup$
                                              Wait... is that divmod? Clever! And I was struggling with p...
                                              $endgroup$
                                              – Erik the Outgolfer
                                              8 hours ago














                                            3












                                            3








                                            3





                                            $begingroup$


                                            Jelly, 4 bytes



                                            Ḷd§‘


                                            A dyadic Link accepting two positive integers, x on the left and n on the right, which yields a list of positive integers.



                                            Try it online!



                                            How?



                                            Ḷd§‘ - Link: x, n e.g 13, 3
                                            Ḷ - lowered range (x) [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                            d - divmod (n) [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                            § - sums [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                            ‘ - increment (vectorises) [1,2,3,2,3,4,3,4,5,4,5,6,5]





                                            share|improve this answer











                                            $endgroup$




                                            Jelly, 4 bytes



                                            Ḷd§‘


                                            A dyadic Link accepting two positive integers, x on the left and n on the right, which yields a list of positive integers.



                                            Try it online!



                                            How?



                                            Ḷd§‘ - Link: x, n e.g 13, 3
                                            Ḷ - lowered range (x) [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                            d - divmod (n) [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                            § - sums [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                            ‘ - increment (vectorises) [1,2,3,2,3,4,3,4,5,4,5,6,5]






                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited 7 hours ago

























                                            answered 8 hours ago









                                            Jonathan AllanJonathan Allan

                                            56k538178




                                            56k538178







                                            • 2




                                              $begingroup$
                                              Wait... is that divmod? Clever! And I was struggling with p...
                                              $endgroup$
                                              – Erik the Outgolfer
                                              8 hours ago













                                            • 2




                                              $begingroup$
                                              Wait... is that divmod? Clever! And I was struggling with p...
                                              $endgroup$
                                              – Erik the Outgolfer
                                              8 hours ago








                                            2




                                            2




                                            $begingroup$
                                            Wait... is that divmod? Clever! And I was struggling with p...
                                            $endgroup$
                                            – Erik the Outgolfer
                                            8 hours ago





                                            $begingroup$
                                            Wait... is that divmod? Clever! And I was struggling with p...
                                            $endgroup$
                                            – Erik the Outgolfer
                                            8 hours ago












                                            3












                                            $begingroup$


                                            R, 33 bytes





                                            function(n,x,z=1:x-1)z%%n+z%/%n+1


                                            Try it online!



                                            Ports Jonathan Allan's Python solution.




                                            R, 36 bytes





                                            function(n,x)outer(1:n,0:x,"+")[1:x]


                                            Try it online!



                                            My original solution; generates an $ntimes x$ matrix with each column as the increments, i.e., $1 ldots n, 2ldots n+1,ldots$, then takes the first $x$ entries (going down the columns).






                                            share|improve this answer











                                            $endgroup$

















                                              3












                                              $begingroup$


                                              R, 33 bytes





                                              function(n,x,z=1:x-1)z%%n+z%/%n+1


                                              Try it online!



                                              Ports Jonathan Allan's Python solution.




                                              R, 36 bytes





                                              function(n,x)outer(1:n,0:x,"+")[1:x]


                                              Try it online!



                                              My original solution; generates an $ntimes x$ matrix with each column as the increments, i.e., $1 ldots n, 2ldots n+1,ldots$, then takes the first $x$ entries (going down the columns).






                                              share|improve this answer











                                              $endgroup$















                                                3












                                                3








                                                3





                                                $begingroup$


                                                R, 33 bytes





                                                function(n,x,z=1:x-1)z%%n+z%/%n+1


                                                Try it online!



                                                Ports Jonathan Allan's Python solution.




                                                R, 36 bytes





                                                function(n,x)outer(1:n,0:x,"+")[1:x]


                                                Try it online!



                                                My original solution; generates an $ntimes x$ matrix with each column as the increments, i.e., $1 ldots n, 2ldots n+1,ldots$, then takes the first $x$ entries (going down the columns).






                                                share|improve this answer











                                                $endgroup$




                                                R, 33 bytes





                                                function(n,x,z=1:x-1)z%%n+z%/%n+1


                                                Try it online!



                                                Ports Jonathan Allan's Python solution.




                                                R, 36 bytes





                                                function(n,x)outer(1:n,0:x,"+")[1:x]


                                                Try it online!



                                                My original solution; generates an $ntimes x$ matrix with each column as the increments, i.e., $1 ldots n, 2ldots n+1,ldots$, then takes the first $x$ entries (going down the columns).







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 7 hours ago

























                                                answered 8 hours ago









                                                GiuseppeGiuseppe

                                                18.6k31358




                                                18.6k31358





















                                                    2












                                                    $begingroup$


                                                    05AB1E, 6 bytes



                                                    L<s‰O>


                                                    Port of @JonathanAllan's Jelly answer, so make sure to upvote him!



                                                    First input is $x$, second input is $n$.



                                                    Try it online or verify all test cases.



                                                    Explanation:





                                                    L # Push a list in the range [1, (implicit) input]
                                                    # i.e. 13 → [1,2,3,4,5,6,7,8,9,10,11,12,13]
                                                    < # Decrease each by 1 to the range [0, input)
                                                    # → [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                                    s‰ # Divmod each by the second input
                                                    # i.e. 3 → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                                    O # Sum each pair
                                                    # → [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                                    > # And increase each by 1
                                                    # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                    # (after which the result is output implicitly)





                                                    My own initial approach was 8 bytes:



                                                    LI∍εN¹÷+


                                                    First input is $n$, second input is $x$.



                                                    Try it online or verify all test cases.



                                                    Explanation:





                                                    L # Push a list in the range [1, (implicit) input]
                                                    # i.e. 3 → [1,2,3]
                                                    I∍ # Extend it to the size of the second input
                                                    # i.e. 13 → [1,2,3,1,2,3,1,2,3,1,2,3,1]
                                                    ε # Map each value to:
                                                    N¹÷ # The 0-based index integer-divided by the first input
                                                    # → [0,0,0,1,1,1,2,2,2,3,3,3,4]
                                                    + # Add that to the value
                                                    # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                    # (after which the result is output implicitly)





                                                    share|improve this answer









                                                    $endgroup$

















                                                      2












                                                      $begingroup$


                                                      05AB1E, 6 bytes



                                                      L<s‰O>


                                                      Port of @JonathanAllan's Jelly answer, so make sure to upvote him!



                                                      First input is $x$, second input is $n$.



                                                      Try it online or verify all test cases.



                                                      Explanation:





                                                      L # Push a list in the range [1, (implicit) input]
                                                      # i.e. 13 → [1,2,3,4,5,6,7,8,9,10,11,12,13]
                                                      < # Decrease each by 1 to the range [0, input)
                                                      # → [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                                      s‰ # Divmod each by the second input
                                                      # i.e. 3 → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                                      O # Sum each pair
                                                      # → [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                                      > # And increase each by 1
                                                      # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                      # (after which the result is output implicitly)





                                                      My own initial approach was 8 bytes:



                                                      LI∍εN¹÷+


                                                      First input is $n$, second input is $x$.



                                                      Try it online or verify all test cases.



                                                      Explanation:





                                                      L # Push a list in the range [1, (implicit) input]
                                                      # i.e. 3 → [1,2,3]
                                                      I∍ # Extend it to the size of the second input
                                                      # i.e. 13 → [1,2,3,1,2,3,1,2,3,1,2,3,1]
                                                      ε # Map each value to:
                                                      N¹÷ # The 0-based index integer-divided by the first input
                                                      # → [0,0,0,1,1,1,2,2,2,3,3,3,4]
                                                      + # Add that to the value
                                                      # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                      # (after which the result is output implicitly)





                                                      share|improve this answer









                                                      $endgroup$















                                                        2












                                                        2








                                                        2





                                                        $begingroup$


                                                        05AB1E, 6 bytes



                                                        L<s‰O>


                                                        Port of @JonathanAllan's Jelly answer, so make sure to upvote him!



                                                        First input is $x$, second input is $n$.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        L # Push a list in the range [1, (implicit) input]
                                                        # i.e. 13 → [1,2,3,4,5,6,7,8,9,10,11,12,13]
                                                        < # Decrease each by 1 to the range [0, input)
                                                        # → [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                                        s‰ # Divmod each by the second input
                                                        # i.e. 3 → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                                        O # Sum each pair
                                                        # → [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                                        > # And increase each by 1
                                                        # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                        # (after which the result is output implicitly)





                                                        My own initial approach was 8 bytes:



                                                        LI∍εN¹÷+


                                                        First input is $n$, second input is $x$.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        L # Push a list in the range [1, (implicit) input]
                                                        # i.e. 3 → [1,2,3]
                                                        I∍ # Extend it to the size of the second input
                                                        # i.e. 13 → [1,2,3,1,2,3,1,2,3,1,2,3,1]
                                                        ε # Map each value to:
                                                        N¹÷ # The 0-based index integer-divided by the first input
                                                        # → [0,0,0,1,1,1,2,2,2,3,3,3,4]
                                                        + # Add that to the value
                                                        # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                        # (after which the result is output implicitly)





                                                        share|improve this answer









                                                        $endgroup$




                                                        05AB1E, 6 bytes



                                                        L<s‰O>


                                                        Port of @JonathanAllan's Jelly answer, so make sure to upvote him!



                                                        First input is $x$, second input is $n$.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        L # Push a list in the range [1, (implicit) input]
                                                        # i.e. 13 → [1,2,3,4,5,6,7,8,9,10,11,12,13]
                                                        < # Decrease each by 1 to the range [0, input)
                                                        # → [0,1,2,3,4,5,6,7,8,9,10,11,12]
                                                        s‰ # Divmod each by the second input
                                                        # i.e. 3 → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2],[3,0],[3,1],[3,2],[4,0]]
                                                        O # Sum each pair
                                                        # → [0,1,2,1,2,3,2,3,4,3,4,5,4]
                                                        > # And increase each by 1
                                                        # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                        # (after which the result is output implicitly)





                                                        My own initial approach was 8 bytes:



                                                        LI∍εN¹÷+


                                                        First input is $n$, second input is $x$.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        L # Push a list in the range [1, (implicit) input]
                                                        # i.e. 3 → [1,2,3]
                                                        I∍ # Extend it to the size of the second input
                                                        # i.e. 13 → [1,2,3,1,2,3,1,2,3,1,2,3,1]
                                                        ε # Map each value to:
                                                        N¹÷ # The 0-based index integer-divided by the first input
                                                        # → [0,0,0,1,1,1,2,2,2,3,3,3,4]
                                                        + # Add that to the value
                                                        # → [1,2,3,2,3,4,3,4,5,4,5,6,5]
                                                        # (after which the result is output implicitly)






                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered 5 hours ago









                                                        Kevin CruijssenKevin Cruijssen

                                                        45.2k576227




                                                        45.2k576227





















                                                            2












                                                            $begingroup$


                                                            Brain-Flak, 100 bytes



                                                            (<>)<>([()]<(())(()[()](<>))<>(()<>)(<>)(<>)([()]<(<>[](())[()]<>)>)>)


                                                            With comments and formatting:



                                                            # Push a zero under the other stack
                                                            (<>)<>

                                                            # x times

                                                            # x - 1
                                                            ([()]<

                                                            # Let 'a' be a counter that starts at n
                                                            # Duplicate a and NOT
                                                            (())(()[()](<>))

                                                            # if a == 0

                                                            # Pop truthy

                                                            <>

                                                            # Reset n to a
                                                            (()<>)

                                                            # Push 0 to each
                                                            (<>)(<>)


                                                            # Pop falsy


                                                            # Decrement A, add one to the other stack, and duplicate that number under this stack
                                                            ([()]<
                                                            (<>[](())<>)
                                                            >)
                                                            >)



                                                            Try it online!






                                                            share|improve this answer











                                                            $endgroup$












                                                            • $begingroup$
                                                              Your "golfed" version doesn't work (and the formatted/commented version on TIO minifies to 100 bytes).
                                                              $endgroup$
                                                              – Nitrodon
                                                              4 hours ago











                                                            • $begingroup$
                                                              @Nitrodon Whoops, not sure how that happened. Fixed now!
                                                              $endgroup$
                                                              – DJMcMayhem
                                                              4 hours ago















                                                            2












                                                            $begingroup$


                                                            Brain-Flak, 100 bytes



                                                            (<>)<>([()]<(())(()[()](<>))<>(()<>)(<>)(<>)([()]<(<>[](())[()]<>)>)>)


                                                            With comments and formatting:



                                                            # Push a zero under the other stack
                                                            (<>)<>

                                                            # x times

                                                            # x - 1
                                                            ([()]<

                                                            # Let 'a' be a counter that starts at n
                                                            # Duplicate a and NOT
                                                            (())(()[()](<>))

                                                            # if a == 0

                                                            # Pop truthy

                                                            <>

                                                            # Reset n to a
                                                            (()<>)

                                                            # Push 0 to each
                                                            (<>)(<>)


                                                            # Pop falsy


                                                            # Decrement A, add one to the other stack, and duplicate that number under this stack
                                                            ([()]<
                                                            (<>[](())<>)
                                                            >)
                                                            >)



                                                            Try it online!






                                                            share|improve this answer











                                                            $endgroup$












                                                            • $begingroup$
                                                              Your "golfed" version doesn't work (and the formatted/commented version on TIO minifies to 100 bytes).
                                                              $endgroup$
                                                              – Nitrodon
                                                              4 hours ago











                                                            • $begingroup$
                                                              @Nitrodon Whoops, not sure how that happened. Fixed now!
                                                              $endgroup$
                                                              – DJMcMayhem
                                                              4 hours ago













                                                            2












                                                            2








                                                            2





                                                            $begingroup$


                                                            Brain-Flak, 100 bytes



                                                            (<>)<>([()]<(())(()[()](<>))<>(()<>)(<>)(<>)([()]<(<>[](())[()]<>)>)>)


                                                            With comments and formatting:



                                                            # Push a zero under the other stack
                                                            (<>)<>

                                                            # x times

                                                            # x - 1
                                                            ([()]<

                                                            # Let 'a' be a counter that starts at n
                                                            # Duplicate a and NOT
                                                            (())(()[()](<>))

                                                            # if a == 0

                                                            # Pop truthy

                                                            <>

                                                            # Reset n to a
                                                            (()<>)

                                                            # Push 0 to each
                                                            (<>)(<>)


                                                            # Pop falsy


                                                            # Decrement A, add one to the other stack, and duplicate that number under this stack
                                                            ([()]<
                                                            (<>[](())<>)
                                                            >)
                                                            >)



                                                            Try it online!






                                                            share|improve this answer











                                                            $endgroup$




                                                            Brain-Flak, 100 bytes



                                                            (<>)<>([()]<(())(()[()](<>))<>(()<>)(<>)(<>)([()]<(<>[](())[()]<>)>)>)


                                                            With comments and formatting:



                                                            # Push a zero under the other stack
                                                            (<>)<>

                                                            # x times

                                                            # x - 1
                                                            ([()]<

                                                            # Let 'a' be a counter that starts at n
                                                            # Duplicate a and NOT
                                                            (())(()[()](<>))

                                                            # if a == 0

                                                            # Pop truthy

                                                            <>

                                                            # Reset n to a
                                                            (()<>)

                                                            # Push 0 to each
                                                            (<>)(<>)


                                                            # Pop falsy


                                                            # Decrement A, add one to the other stack, and duplicate that number under this stack
                                                            ([()]<
                                                            (<>[](())<>)
                                                            >)
                                                            >)



                                                            Try it online!







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited 4 hours ago

























                                                            answered 8 hours ago









                                                            DJMcMayhemDJMcMayhem

                                                            40.8k12150317




                                                            40.8k12150317











                                                            • $begingroup$
                                                              Your "golfed" version doesn't work (and the formatted/commented version on TIO minifies to 100 bytes).
                                                              $endgroup$
                                                              – Nitrodon
                                                              4 hours ago











                                                            • $begingroup$
                                                              @Nitrodon Whoops, not sure how that happened. Fixed now!
                                                              $endgroup$
                                                              – DJMcMayhem
                                                              4 hours ago
















                                                            • $begingroup$
                                                              Your "golfed" version doesn't work (and the formatted/commented version on TIO minifies to 100 bytes).
                                                              $endgroup$
                                                              – Nitrodon
                                                              4 hours ago











                                                            • $begingroup$
                                                              @Nitrodon Whoops, not sure how that happened. Fixed now!
                                                              $endgroup$
                                                              – DJMcMayhem
                                                              4 hours ago















                                                            $begingroup$
                                                            Your "golfed" version doesn't work (and the formatted/commented version on TIO minifies to 100 bytes).
                                                            $endgroup$
                                                            – Nitrodon
                                                            4 hours ago





                                                            $begingroup$
                                                            Your "golfed" version doesn't work (and the formatted/commented version on TIO minifies to 100 bytes).
                                                            $endgroup$
                                                            – Nitrodon
                                                            4 hours ago













                                                            $begingroup$
                                                            @Nitrodon Whoops, not sure how that happened. Fixed now!
                                                            $endgroup$
                                                            – DJMcMayhem
                                                            4 hours ago




                                                            $begingroup$
                                                            @Nitrodon Whoops, not sure how that happened. Fixed now!
                                                            $endgroup$
                                                            – DJMcMayhem
                                                            4 hours ago











                                                            1












                                                            $begingroup$


                                                            Jelly, 5 bytes



                                                            +þẎḣ’


                                                            Try it online!






                                                            share|improve this answer









                                                            $endgroup$

















                                                              1












                                                              $begingroup$


                                                              Jelly, 5 bytes



                                                              +þẎḣ’


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$















                                                                1












                                                                1








                                                                1





                                                                $begingroup$


                                                                Jelly, 5 bytes



                                                                +þẎḣ’


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$




                                                                Jelly, 5 bytes



                                                                +þẎḣ’


                                                                Try it online!







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered 8 hours ago









                                                                Erik the OutgolferErik the Outgolfer

                                                                33.6k430106




                                                                33.6k430106





















                                                                    1












                                                                    $begingroup$


                                                                    Ruby, 32 bytes





                                                                    ->n,x(0...x).map


                                                                    Try it online!






                                                                    share|improve this answer









                                                                    $endgroup$

















                                                                      1












                                                                      $begingroup$


                                                                      Ruby, 32 bytes





                                                                      ->n,x(0...x).map


                                                                      Try it online!






                                                                      share|improve this answer









                                                                      $endgroup$















                                                                        1












                                                                        1








                                                                        1





                                                                        $begingroup$


                                                                        Ruby, 32 bytes





                                                                        ->n,x(0...x).map


                                                                        Try it online!






                                                                        share|improve this answer









                                                                        $endgroup$




                                                                        Ruby, 32 bytes





                                                                        ->n,x(0...x).map


                                                                        Try it online!







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered 7 hours ago









                                                                        Value InkValue Ink

                                                                        8,215731




                                                                        8,215731





















                                                                            1












                                                                            $begingroup$


                                                                            Japt -m, 12 7 bytes



                                                                            Port of Jonathan's Python solution.



                                                                            Takes x as the first input.



                                                                            %VÄ+UzV


                                                                            Try it






                                                                            share|improve this answer











                                                                            $endgroup$

















                                                                              1












                                                                              $begingroup$


                                                                              Japt -m, 12 7 bytes



                                                                              Port of Jonathan's Python solution.



                                                                              Takes x as the first input.



                                                                              %VÄ+UzV


                                                                              Try it






                                                                              share|improve this answer











                                                                              $endgroup$















                                                                                1












                                                                                1








                                                                                1





                                                                                $begingroup$


                                                                                Japt -m, 12 7 bytes



                                                                                Port of Jonathan's Python solution.



                                                                                Takes x as the first input.



                                                                                %VÄ+UzV


                                                                                Try it






                                                                                share|improve this answer











                                                                                $endgroup$




                                                                                Japt -m, 12 7 bytes



                                                                                Port of Jonathan's Python solution.



                                                                                Takes x as the first input.



                                                                                %VÄ+UzV


                                                                                Try it







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited 6 hours ago

























                                                                                answered 8 hours ago









                                                                                ShaggyShaggy

                                                                                19.6k31768




                                                                                19.6k31768





















                                                                                    1












                                                                                    $begingroup$


                                                                                    Perl 6, 18 bytes





                                                                                    (1..*X+ ^*)[^$_]


                                                                                    Try it online!



                                                                                    Curried function f(x)(n).



                                                                                    Explanation



                                                                                     # Anonymous block
                                                                                    X+ # Cartesian product with addition
                                                                                    1..* # of range 1..Inf
                                                                                    ^* # and range 0..n
                                                                                    ( )[^$_] # First x elements





                                                                                    share|improve this answer











                                                                                    $endgroup$

















                                                                                      1












                                                                                      $begingroup$


                                                                                      Perl 6, 18 bytes





                                                                                      (1..*X+ ^*)[^$_]


                                                                                      Try it online!



                                                                                      Curried function f(x)(n).



                                                                                      Explanation



                                                                                       # Anonymous block
                                                                                      X+ # Cartesian product with addition
                                                                                      1..* # of range 1..Inf
                                                                                      ^* # and range 0..n
                                                                                      ( )[^$_] # First x elements





                                                                                      share|improve this answer











                                                                                      $endgroup$















                                                                                        1












                                                                                        1








                                                                                        1





                                                                                        $begingroup$


                                                                                        Perl 6, 18 bytes





                                                                                        (1..*X+ ^*)[^$_]


                                                                                        Try it online!



                                                                                        Curried function f(x)(n).



                                                                                        Explanation



                                                                                         # Anonymous block
                                                                                        X+ # Cartesian product with addition
                                                                                        1..* # of range 1..Inf
                                                                                        ^* # and range 0..n
                                                                                        ( )[^$_] # First x elements





                                                                                        share|improve this answer











                                                                                        $endgroup$




                                                                                        Perl 6, 18 bytes





                                                                                        (1..*X+ ^*)[^$_]


                                                                                        Try it online!



                                                                                        Curried function f(x)(n).



                                                                                        Explanation



                                                                                         # Anonymous block
                                                                                        X+ # Cartesian product with addition
                                                                                        1..* # of range 1..Inf
                                                                                        ^* # and range 0..n
                                                                                        ( )[^$_] # First x elements






                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 6 hours ago

























                                                                                        answered 6 hours ago









                                                                                        nwellnhofnwellnhof

                                                                                        7,70011129




                                                                                        7,70011129





















                                                                                            1












                                                                                            $begingroup$


                                                                                            Perl 5 -na, 43 bytes





                                                                                            @r=map$_..$_+$F[1]-1,1..$_;say"@r[0..$_-1]"


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$

















                                                                                              1












                                                                                              $begingroup$


                                                                                              Perl 5 -na, 43 bytes





                                                                                              @r=map$_..$_+$F[1]-1,1..$_;say"@r[0..$_-1]"


                                                                                              Try it online!






                                                                                              share|improve this answer









                                                                                              $endgroup$















                                                                                                1












                                                                                                1








                                                                                                1





                                                                                                $begingroup$


                                                                                                Perl 5 -na, 43 bytes





                                                                                                @r=map$_..$_+$F[1]-1,1..$_;say"@r[0..$_-1]"


                                                                                                Try it online!






                                                                                                share|improve this answer









                                                                                                $endgroup$




                                                                                                Perl 5 -na, 43 bytes





                                                                                                @r=map$_..$_+$F[1]-1,1..$_;say"@r[0..$_-1]"


                                                                                                Try it online!







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered 5 hours ago









                                                                                                XcaliXcali

                                                                                                5,920523




                                                                                                5,920523





















                                                                                                    1












                                                                                                    $begingroup$


                                                                                                    Octave, 25 bytes





                                                                                                    @(n,x)((1:n)'+(0:x))(1:x)


                                                                                                    Anonymous function that inputs numbers n``andx`, and outputs a row vector.



                                                                                                    Try it online!






                                                                                                    share|improve this answer









                                                                                                    $endgroup$

















                                                                                                      1












                                                                                                      $begingroup$


                                                                                                      Octave, 25 bytes





                                                                                                      @(n,x)((1:n)'+(0:x))(1:x)


                                                                                                      Anonymous function that inputs numbers n``andx`, and outputs a row vector.



                                                                                                      Try it online!






                                                                                                      share|improve this answer









                                                                                                      $endgroup$















                                                                                                        1












                                                                                                        1








                                                                                                        1





                                                                                                        $begingroup$


                                                                                                        Octave, 25 bytes





                                                                                                        @(n,x)((1:n)'+(0:x))(1:x)


                                                                                                        Anonymous function that inputs numbers n``andx`, and outputs a row vector.



                                                                                                        Try it online!






                                                                                                        share|improve this answer









                                                                                                        $endgroup$




                                                                                                        Octave, 25 bytes





                                                                                                        @(n,x)((1:n)'+(0:x))(1:x)


                                                                                                        Anonymous function that inputs numbers n``andx`, and outputs a row vector.



                                                                                                        Try it online!







                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered 5 hours ago









                                                                                                        Luis MendoLuis Mendo

                                                                                                        76k889298




                                                                                                        76k889298





















                                                                                                            1












                                                                                                            $begingroup$


                                                                                                            MATL, 16 bytes



                                                                                                            :i:"tQ]v!1e 2G:)


                                                                                                            Try it online!



                                                                                                            Explanation:



                                                                                                            : % Push [1, 2... n]
                                                                                                            i:" ] % For i in [1, x]:
                                                                                                            t % Duplicate the first array
                                                                                                            Q % Increment each number
                                                                                                            v % Concatenate everything into 1 matrix
                                                                                                            ! % Transpose
                                                                                                            1e % Reshape into 1 row
                                                                                                            2G % Push x again
                                                                                                            :) % And take the first x elements





                                                                                                            share|improve this answer









                                                                                                            $endgroup$








                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              10 bytes using broadcasting.
                                                                                                              $endgroup$
                                                                                                              – Giuseppe
                                                                                                              3 hours ago















                                                                                                            1












                                                                                                            $begingroup$


                                                                                                            MATL, 16 bytes



                                                                                                            :i:"tQ]v!1e 2G:)


                                                                                                            Try it online!



                                                                                                            Explanation:



                                                                                                            : % Push [1, 2... n]
                                                                                                            i:" ] % For i in [1, x]:
                                                                                                            t % Duplicate the first array
                                                                                                            Q % Increment each number
                                                                                                            v % Concatenate everything into 1 matrix
                                                                                                            ! % Transpose
                                                                                                            1e % Reshape into 1 row
                                                                                                            2G % Push x again
                                                                                                            :) % And take the first x elements





                                                                                                            share|improve this answer









                                                                                                            $endgroup$








                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              10 bytes using broadcasting.
                                                                                                              $endgroup$
                                                                                                              – Giuseppe
                                                                                                              3 hours ago













                                                                                                            1












                                                                                                            1








                                                                                                            1





                                                                                                            $begingroup$


                                                                                                            MATL, 16 bytes



                                                                                                            :i:"tQ]v!1e 2G:)


                                                                                                            Try it online!



                                                                                                            Explanation:



                                                                                                            : % Push [1, 2... n]
                                                                                                            i:" ] % For i in [1, x]:
                                                                                                            t % Duplicate the first array
                                                                                                            Q % Increment each number
                                                                                                            v % Concatenate everything into 1 matrix
                                                                                                            ! % Transpose
                                                                                                            1e % Reshape into 1 row
                                                                                                            2G % Push x again
                                                                                                            :) % And take the first x elements





                                                                                                            share|improve this answer









                                                                                                            $endgroup$




                                                                                                            MATL, 16 bytes



                                                                                                            :i:"tQ]v!1e 2G:)


                                                                                                            Try it online!



                                                                                                            Explanation:



                                                                                                            : % Push [1, 2... n]
                                                                                                            i:" ] % For i in [1, x]:
                                                                                                            t % Duplicate the first array
                                                                                                            Q % Increment each number
                                                                                                            v % Concatenate everything into 1 matrix
                                                                                                            ! % Transpose
                                                                                                            1e % Reshape into 1 row
                                                                                                            2G % Push x again
                                                                                                            :) % And take the first x elements






                                                                                                            share|improve this answer












                                                                                                            share|improve this answer



                                                                                                            share|improve this answer










                                                                                                            answered 3 hours ago









                                                                                                            DJMcMayhemDJMcMayhem

                                                                                                            40.8k12150317




                                                                                                            40.8k12150317







                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              10 bytes using broadcasting.
                                                                                                              $endgroup$
                                                                                                              – Giuseppe
                                                                                                              3 hours ago












                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              10 bytes using broadcasting.
                                                                                                              $endgroup$
                                                                                                              – Giuseppe
                                                                                                              3 hours ago







                                                                                                            1




                                                                                                            1




                                                                                                            $begingroup$
                                                                                                            10 bytes using broadcasting.
                                                                                                            $endgroup$
                                                                                                            – Giuseppe
                                                                                                            3 hours ago




                                                                                                            $begingroup$
                                                                                                            10 bytes using broadcasting.
                                                                                                            $endgroup$
                                                                                                            – Giuseppe
                                                                                                            3 hours ago











                                                                                                            1












                                                                                                            $begingroup$


                                                                                                            J, 13 12 bytes



                                                                                                            [$[:,1++/&i.


                                                                                                            Try it online!



                                                                                                            how



                                                                                                            We take x as the left arg, n as the right. Let's take x = 8 and n = 3 for this example:




                                                                                                            • +/&i.: Transform both args by creating integer ranges i., that is, the left arg becomes 0 1 2 3 4 5 6 7 and the right arg becomes 0 1 2. Now we create an "addition table +/ from those two:



                                                                                                               0 1 2
                                                                                                              1 2 3
                                                                                                              2 3 4
                                                                                                              3 4 5
                                                                                                              4 5 6
                                                                                                              5 6 7
                                                                                                              6 7 8
                                                                                                              7 8 9



                                                                                                            • 1 +: Add 1 to every element of this table:



                                                                                                               1 2 3
                                                                                                              2 3 4
                                                                                                              3 4 5
                                                                                                              4 5 6
                                                                                                              5 6 7
                                                                                                              6 7 8
                                                                                                              7 8 9
                                                                                                              8 9 10



                                                                                                            • [: ,: Flatten it ,:



                                                                                                               1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10



                                                                                                            • [ $: Shape it $ so it has the same number of elements as the original, untransformed left arg [, ie, x:



                                                                                                               1 2 3 2 3 4 3 4 






                                                                                                            share|improve this answer











                                                                                                            $endgroup$

















                                                                                                              1












                                                                                                              $begingroup$


                                                                                                              J, 13 12 bytes



                                                                                                              [$[:,1++/&i.


                                                                                                              Try it online!



                                                                                                              how



                                                                                                              We take x as the left arg, n as the right. Let's take x = 8 and n = 3 for this example:




                                                                                                              • +/&i.: Transform both args by creating integer ranges i., that is, the left arg becomes 0 1 2 3 4 5 6 7 and the right arg becomes 0 1 2. Now we create an "addition table +/ from those two:



                                                                                                                 0 1 2
                                                                                                                1 2 3
                                                                                                                2 3 4
                                                                                                                3 4 5
                                                                                                                4 5 6
                                                                                                                5 6 7
                                                                                                                6 7 8
                                                                                                                7 8 9



                                                                                                              • 1 +: Add 1 to every element of this table:



                                                                                                                 1 2 3
                                                                                                                2 3 4
                                                                                                                3 4 5
                                                                                                                4 5 6
                                                                                                                5 6 7
                                                                                                                6 7 8
                                                                                                                7 8 9
                                                                                                                8 9 10



                                                                                                              • [: ,: Flatten it ,:



                                                                                                                 1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10



                                                                                                              • [ $: Shape it $ so it has the same number of elements as the original, untransformed left arg [, ie, x:



                                                                                                                 1 2 3 2 3 4 3 4 






                                                                                                              share|improve this answer











                                                                                                              $endgroup$















                                                                                                                1












                                                                                                                1








                                                                                                                1





                                                                                                                $begingroup$


                                                                                                                J, 13 12 bytes



                                                                                                                [$[:,1++/&i.


                                                                                                                Try it online!



                                                                                                                how



                                                                                                                We take x as the left arg, n as the right. Let's take x = 8 and n = 3 for this example:




                                                                                                                • +/&i.: Transform both args by creating integer ranges i., that is, the left arg becomes 0 1 2 3 4 5 6 7 and the right arg becomes 0 1 2. Now we create an "addition table +/ from those two:



                                                                                                                   0 1 2
                                                                                                                  1 2 3
                                                                                                                  2 3 4
                                                                                                                  3 4 5
                                                                                                                  4 5 6
                                                                                                                  5 6 7
                                                                                                                  6 7 8
                                                                                                                  7 8 9



                                                                                                                • 1 +: Add 1 to every element of this table:



                                                                                                                   1 2 3
                                                                                                                  2 3 4
                                                                                                                  3 4 5
                                                                                                                  4 5 6
                                                                                                                  5 6 7
                                                                                                                  6 7 8
                                                                                                                  7 8 9
                                                                                                                  8 9 10



                                                                                                                • [: ,: Flatten it ,:



                                                                                                                   1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10



                                                                                                                • [ $: Shape it $ so it has the same number of elements as the original, untransformed left arg [, ie, x:



                                                                                                                   1 2 3 2 3 4 3 4 






                                                                                                                share|improve this answer











                                                                                                                $endgroup$




                                                                                                                J, 13 12 bytes



                                                                                                                [$[:,1++/&i.


                                                                                                                Try it online!



                                                                                                                how



                                                                                                                We take x as the left arg, n as the right. Let's take x = 8 and n = 3 for this example:




                                                                                                                • +/&i.: Transform both args by creating integer ranges i., that is, the left arg becomes 0 1 2 3 4 5 6 7 and the right arg becomes 0 1 2. Now we create an "addition table +/ from those two:



                                                                                                                   0 1 2
                                                                                                                  1 2 3
                                                                                                                  2 3 4
                                                                                                                  3 4 5
                                                                                                                  4 5 6
                                                                                                                  5 6 7
                                                                                                                  6 7 8
                                                                                                                  7 8 9



                                                                                                                • 1 +: Add 1 to every element of this table:



                                                                                                                   1 2 3
                                                                                                                  2 3 4
                                                                                                                  3 4 5
                                                                                                                  4 5 6
                                                                                                                  5 6 7
                                                                                                                  6 7 8
                                                                                                                  7 8 9
                                                                                                                  8 9 10



                                                                                                                • [: ,: Flatten it ,:



                                                                                                                   1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10



                                                                                                                • [ $: Shape it $ so it has the same number of elements as the original, untransformed left arg [, ie, x:



                                                                                                                   1 2 3 2 3 4 3 4 







                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited 26 mins ago

























                                                                                                                answered 7 hours ago









                                                                                                                JonahJonah

                                                                                                                3,3881019




                                                                                                                3,3881019





















                                                                                                                    0












                                                                                                                    $begingroup$


                                                                                                                    Alchemist, 77 bytes



                                                                                                                    _->In_n+In_x
                                                                                                                    x+n+0y+0z->a+Out_a+Out_" "+m+y
                                                                                                                    y+n->n
                                                                                                                    y+0n->z
                                                                                                                    z+m+a->z+n
                                                                                                                    z+0m->a


                                                                                                                    Try it online!



                                                                                                                    Increments and outputs a counter n times, then subtracts n-1 before repeating.






                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$

















                                                                                                                      0












                                                                                                                      $begingroup$


                                                                                                                      Alchemist, 77 bytes



                                                                                                                      _->In_n+In_x
                                                                                                                      x+n+0y+0z->a+Out_a+Out_" "+m+y
                                                                                                                      y+n->n
                                                                                                                      y+0n->z
                                                                                                                      z+m+a->z+n
                                                                                                                      z+0m->a


                                                                                                                      Try it online!



                                                                                                                      Increments and outputs a counter n times, then subtracts n-1 before repeating.






                                                                                                                      share|improve this answer









                                                                                                                      $endgroup$















                                                                                                                        0












                                                                                                                        0








                                                                                                                        0





                                                                                                                        $begingroup$


                                                                                                                        Alchemist, 77 bytes



                                                                                                                        _->In_n+In_x
                                                                                                                        x+n+0y+0z->a+Out_a+Out_" "+m+y
                                                                                                                        y+n->n
                                                                                                                        y+0n->z
                                                                                                                        z+m+a->z+n
                                                                                                                        z+0m->a


                                                                                                                        Try it online!



                                                                                                                        Increments and outputs a counter n times, then subtracts n-1 before repeating.






                                                                                                                        share|improve this answer









                                                                                                                        $endgroup$




                                                                                                                        Alchemist, 77 bytes



                                                                                                                        _->In_n+In_x
                                                                                                                        x+n+0y+0z->a+Out_a+Out_" "+m+y
                                                                                                                        y+n->n
                                                                                                                        y+0n->z
                                                                                                                        z+m+a->z+n
                                                                                                                        z+0m->a


                                                                                                                        Try it online!



                                                                                                                        Increments and outputs a counter n times, then subtracts n-1 before repeating.







                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered 8 hours ago









                                                                                                                        NitrodonNitrodon

                                                                                                                        8,03621024




                                                                                                                        8,03621024





















                                                                                                                            0












                                                                                                                            $begingroup$


                                                                                                                            Charcoal, 18 bytes



                                                                                                                            NθFN⊞υ⊕⎇‹ιθι§υ±θIυ


                                                                                                                            Try it online! Link is to verbose version of code. I had dreams of seeding the list with a zero-indexed range and then slicing it off again but that was actually 2 bytes longer. Explanation:



                                                                                                                            Nθ Input `n` into variable
                                                                                                                            N Input `x`
                                                                                                                            F Loop over implicit range
                                                                                                                            ι Current index
                                                                                                                            ‹ Less than
                                                                                                                            θ Variable `n`
                                                                                                                            ⎇ ι Then current index else
                                                                                                                            θ Variable `n`
                                                                                                                            ± Negated
                                                                                                                            §υ Cyclically indexed into list
                                                                                                                            ⊕ Incremented
                                                                                                                            ⊞υ Pushed to list
                                                                                                                            Iυ Cast list to string for implicit output





                                                                                                                            share|improve this answer









                                                                                                                            $endgroup$

















                                                                                                                              0












                                                                                                                              $begingroup$


                                                                                                                              Charcoal, 18 bytes



                                                                                                                              NθFN⊞υ⊕⎇‹ιθι§υ±θIυ


                                                                                                                              Try it online! Link is to verbose version of code. I had dreams of seeding the list with a zero-indexed range and then slicing it off again but that was actually 2 bytes longer. Explanation:



                                                                                                                              Nθ Input `n` into variable
                                                                                                                              N Input `x`
                                                                                                                              F Loop over implicit range
                                                                                                                              ι Current index
                                                                                                                              ‹ Less than
                                                                                                                              θ Variable `n`
                                                                                                                              ⎇ ι Then current index else
                                                                                                                              θ Variable `n`
                                                                                                                              ± Negated
                                                                                                                              §υ Cyclically indexed into list
                                                                                                                              ⊕ Incremented
                                                                                                                              ⊞υ Pushed to list
                                                                                                                              Iυ Cast list to string for implicit output





                                                                                                                              share|improve this answer









                                                                                                                              $endgroup$















                                                                                                                                0












                                                                                                                                0








                                                                                                                                0





                                                                                                                                $begingroup$


                                                                                                                                Charcoal, 18 bytes



                                                                                                                                NθFN⊞υ⊕⎇‹ιθι§υ±θIυ


                                                                                                                                Try it online! Link is to verbose version of code. I had dreams of seeding the list with a zero-indexed range and then slicing it off again but that was actually 2 bytes longer. Explanation:



                                                                                                                                Nθ Input `n` into variable
                                                                                                                                N Input `x`
                                                                                                                                F Loop over implicit range
                                                                                                                                ι Current index
                                                                                                                                ‹ Less than
                                                                                                                                θ Variable `n`
                                                                                                                                ⎇ ι Then current index else
                                                                                                                                θ Variable `n`
                                                                                                                                ± Negated
                                                                                                                                §υ Cyclically indexed into list
                                                                                                                                ⊕ Incremented
                                                                                                                                ⊞υ Pushed to list
                                                                                                                                Iυ Cast list to string for implicit output





                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$




                                                                                                                                Charcoal, 18 bytes



                                                                                                                                NθFN⊞υ⊕⎇‹ιθι§υ±θIυ


                                                                                                                                Try it online! Link is to verbose version of code. I had dreams of seeding the list with a zero-indexed range and then slicing it off again but that was actually 2 bytes longer. Explanation:



                                                                                                                                Nθ Input `n` into variable
                                                                                                                                N Input `x`
                                                                                                                                F Loop over implicit range
                                                                                                                                ι Current index
                                                                                                                                ‹ Less than
                                                                                                                                θ Variable `n`
                                                                                                                                ⎇ ι Then current index else
                                                                                                                                θ Variable `n`
                                                                                                                                ± Negated
                                                                                                                                §υ Cyclically indexed into list
                                                                                                                                ⊕ Incremented
                                                                                                                                ⊞υ Pushed to list
                                                                                                                                Iυ Cast list to string for implicit output






                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered 8 hours ago









                                                                                                                                NeilNeil

                                                                                                                                84.6k845183




                                                                                                                                84.6k845183





















                                                                                                                                    0












                                                                                                                                    $begingroup$

                                                                                                                                    APL+WIN, 29 23 bytes



                                                                                                                                    x↑,(0,⍳⌊(x←⎕)÷n)∘.+⍳n←⎕


                                                                                                                                    Prompts for n and x



                                                                                                                                    Try it online! Courtesy of Dyalog Classic






                                                                                                                                    share|improve this answer











                                                                                                                                    $endgroup$

















                                                                                                                                      0












                                                                                                                                      $begingroup$

                                                                                                                                      APL+WIN, 29 23 bytes



                                                                                                                                      x↑,(0,⍳⌊(x←⎕)÷n)∘.+⍳n←⎕


                                                                                                                                      Prompts for n and x



                                                                                                                                      Try it online! Courtesy of Dyalog Classic






                                                                                                                                      share|improve this answer











                                                                                                                                      $endgroup$















                                                                                                                                        0












                                                                                                                                        0








                                                                                                                                        0





                                                                                                                                        $begingroup$

                                                                                                                                        APL+WIN, 29 23 bytes



                                                                                                                                        x↑,(0,⍳⌊(x←⎕)÷n)∘.+⍳n←⎕


                                                                                                                                        Prompts for n and x



                                                                                                                                        Try it online! Courtesy of Dyalog Classic






                                                                                                                                        share|improve this answer











                                                                                                                                        $endgroup$



                                                                                                                                        APL+WIN, 29 23 bytes



                                                                                                                                        x↑,(0,⍳⌊(x←⎕)÷n)∘.+⍳n←⎕


                                                                                                                                        Prompts for n and x



                                                                                                                                        Try it online! Courtesy of Dyalog Classic







                                                                                                                                        share|improve this answer














                                                                                                                                        share|improve this answer



                                                                                                                                        share|improve this answer








                                                                                                                                        edited 6 hours ago

























                                                                                                                                        answered 7 hours ago









                                                                                                                                        GrahamGraham

                                                                                                                                        2,75678




                                                                                                                                        2,75678





















                                                                                                                                            0












                                                                                                                                            $begingroup$

                                                                                                                                            JS, 54 bytes



                                                                                                                                            f=(n,x)=>Array.from(Array(x),(_,i)=>i+1-(i/n|0)*(n-1))


                                                                                                                                            Try it online!






                                                                                                                                            share|improve this answer








                                                                                                                                            New contributor



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





                                                                                                                                            $endgroup$

















                                                                                                                                              0












                                                                                                                                              $begingroup$

                                                                                                                                              JS, 54 bytes



                                                                                                                                              f=(n,x)=>Array.from(Array(x),(_,i)=>i+1-(i/n|0)*(n-1))


                                                                                                                                              Try it online!






                                                                                                                                              share|improve this answer








                                                                                                                                              New contributor



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





                                                                                                                                              $endgroup$















                                                                                                                                                0












                                                                                                                                                0








                                                                                                                                                0





                                                                                                                                                $begingroup$

                                                                                                                                                JS, 54 bytes



                                                                                                                                                f=(n,x)=>Array.from(Array(x),(_,i)=>i+1-(i/n|0)*(n-1))


                                                                                                                                                Try it online!






                                                                                                                                                share|improve this answer








                                                                                                                                                New contributor



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





                                                                                                                                                $endgroup$



                                                                                                                                                JS, 54 bytes



                                                                                                                                                f=(n,x)=>Array.from(Array(x),(_,i)=>i+1-(i/n|0)*(n-1))


                                                                                                                                                Try it online!







                                                                                                                                                share|improve this answer








                                                                                                                                                New contributor



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








                                                                                                                                                share|improve this answer



                                                                                                                                                share|improve this answer






                                                                                                                                                New contributor



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








                                                                                                                                                answered 6 hours ago









                                                                                                                                                user2657799user2657799

                                                                                                                                                1




                                                                                                                                                1




                                                                                                                                                New contributor



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




                                                                                                                                                New contributor




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























                                                                                                                                                    0












                                                                                                                                                    $begingroup$

                                                                                                                                                    Haskell, 34 33 bytes



                                                                                                                                                    n#x=take x$do j<-[1..];[j..j+n-1]


                                                                                                                                                    Try it online!






                                                                                                                                                    share|improve this answer











                                                                                                                                                    $endgroup$

















                                                                                                                                                      0












                                                                                                                                                      $begingroup$

                                                                                                                                                      Haskell, 34 33 bytes



                                                                                                                                                      n#x=take x$do j<-[1..];[j..j+n-1]


                                                                                                                                                      Try it online!






                                                                                                                                                      share|improve this answer











                                                                                                                                                      $endgroup$















                                                                                                                                                        0












                                                                                                                                                        0








                                                                                                                                                        0





                                                                                                                                                        $begingroup$

                                                                                                                                                        Haskell, 34 33 bytes



                                                                                                                                                        n#x=take x$do j<-[1..];[j..j+n-1]


                                                                                                                                                        Try it online!






                                                                                                                                                        share|improve this answer











                                                                                                                                                        $endgroup$



                                                                                                                                                        Haskell, 34 33 bytes



                                                                                                                                                        n#x=take x$do j<-[1..];[j..j+n-1]


                                                                                                                                                        Try it online!







                                                                                                                                                        share|improve this answer














                                                                                                                                                        share|improve this answer



                                                                                                                                                        share|improve this answer








                                                                                                                                                        edited 6 hours ago

























                                                                                                                                                        answered 6 hours ago









                                                                                                                                                        niminimi

                                                                                                                                                        33.2k32491




                                                                                                                                                        33.2k32491





















                                                                                                                                                            0












                                                                                                                                                            $begingroup$

                                                                                                                                                            JavaScript, 36 bytes



                                                                                                                                                            n=>g=x=>x?[...g(--x),1+x%n+x/n|0]:[]


                                                                                                                                                            Try It Online!






                                                                                                                                                            share|improve this answer











                                                                                                                                                            $endgroup$

















                                                                                                                                                              0












                                                                                                                                                              $begingroup$

                                                                                                                                                              JavaScript, 36 bytes



                                                                                                                                                              n=>g=x=>x?[...g(--x),1+x%n+x/n|0]:[]


                                                                                                                                                              Try It Online!






                                                                                                                                                              share|improve this answer











                                                                                                                                                              $endgroup$















                                                                                                                                                                0












                                                                                                                                                                0








                                                                                                                                                                0





                                                                                                                                                                $begingroup$

                                                                                                                                                                JavaScript, 36 bytes



                                                                                                                                                                n=>g=x=>x?[...g(--x),1+x%n+x/n|0]:[]


                                                                                                                                                                Try It Online!






                                                                                                                                                                share|improve this answer











                                                                                                                                                                $endgroup$



                                                                                                                                                                JavaScript, 36 bytes



                                                                                                                                                                n=>g=x=>x?[...g(--x),1+x%n+x/n|0]:[]


                                                                                                                                                                Try It Online!







                                                                                                                                                                share|improve this answer














                                                                                                                                                                share|improve this answer



                                                                                                                                                                share|improve this answer








                                                                                                                                                                edited 6 hours ago

























                                                                                                                                                                answered 6 hours ago









                                                                                                                                                                ShaggyShaggy

                                                                                                                                                                19.6k31768




                                                                                                                                                                19.6k31768





















                                                                                                                                                                    0












                                                                                                                                                                    $begingroup$


                                                                                                                                                                    C (gcc), 49 bytes





                                                                                                                                                                    f(n,x,i)for(i=0;x--;)printf("%d ",i%n+i++/n+1);


                                                                                                                                                                    Try it online!






                                                                                                                                                                    share|improve this answer









                                                                                                                                                                    $endgroup$

















                                                                                                                                                                      0












                                                                                                                                                                      $begingroup$


                                                                                                                                                                      C (gcc), 49 bytes





                                                                                                                                                                      f(n,x,i)for(i=0;x--;)printf("%d ",i%n+i++/n+1);


                                                                                                                                                                      Try it online!






                                                                                                                                                                      share|improve this answer









                                                                                                                                                                      $endgroup$















                                                                                                                                                                        0












                                                                                                                                                                        0








                                                                                                                                                                        0





                                                                                                                                                                        $begingroup$


                                                                                                                                                                        C (gcc), 49 bytes





                                                                                                                                                                        f(n,x,i)for(i=0;x--;)printf("%d ",i%n+i++/n+1);


                                                                                                                                                                        Try it online!






                                                                                                                                                                        share|improve this answer









                                                                                                                                                                        $endgroup$




                                                                                                                                                                        C (gcc), 49 bytes





                                                                                                                                                                        f(n,x,i)for(i=0;x--;)printf("%d ",i%n+i++/n+1);


                                                                                                                                                                        Try it online!







                                                                                                                                                                        share|improve this answer












                                                                                                                                                                        share|improve this answer



                                                                                                                                                                        share|improve this answer










                                                                                                                                                                        answered 1 hour ago









                                                                                                                                                                        ErikFErikF

                                                                                                                                                                        1,35927




                                                                                                                                                                        1,35927





















                                                                                                                                                                            0












                                                                                                                                                                            $begingroup$


                                                                                                                                                                            Perl 5, 39 bytes





                                                                                                                                                                            say 1+int($_/$F[1])+$_%$F[1]for 0..$_-1


                                                                                                                                                                            Try it online!






                                                                                                                                                                            share|improve this answer









                                                                                                                                                                            $endgroup$

















                                                                                                                                                                              0












                                                                                                                                                                              $begingroup$


                                                                                                                                                                              Perl 5, 39 bytes





                                                                                                                                                                              say 1+int($_/$F[1])+$_%$F[1]for 0..$_-1


                                                                                                                                                                              Try it online!






                                                                                                                                                                              share|improve this answer









                                                                                                                                                                              $endgroup$















                                                                                                                                                                                0












                                                                                                                                                                                0








                                                                                                                                                                                0





                                                                                                                                                                                $begingroup$


                                                                                                                                                                                Perl 5, 39 bytes





                                                                                                                                                                                say 1+int($_/$F[1])+$_%$F[1]for 0..$_-1


                                                                                                                                                                                Try it online!






                                                                                                                                                                                share|improve this answer









                                                                                                                                                                                $endgroup$




                                                                                                                                                                                Perl 5, 39 bytes





                                                                                                                                                                                say 1+int($_/$F[1])+$_%$F[1]for 0..$_-1


                                                                                                                                                                                Try it online!







                                                                                                                                                                                share|improve this answer












                                                                                                                                                                                share|improve this answer



                                                                                                                                                                                share|improve this answer










                                                                                                                                                                                answered 48 mins ago









                                                                                                                                                                                Kjetil S.Kjetil S.

                                                                                                                                                                                66925




                                                                                                                                                                                66925



























                                                                                                                                                                                    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%2f186233%2fincremental-ranges%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

                                                                                                                                                                                    19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу

                                                                                                                                                                                    Israel Cuprins Etimologie | Istorie | Geografie | Politică | Demografie | Educație | Economie | Cultură | Note explicative | Note bibliografice | Bibliografie | Legături externe | Meniu de navigaresite web oficialfacebooktweeterGoogle+Instagramcanal YouTubeInstagramtextmodificaremodificarewww.technion.ac.ilnew.huji.ac.ilwww.weizmann.ac.ilwww1.biu.ac.ilenglish.tau.ac.ilwww.haifa.ac.ilin.bgu.ac.ilwww.openu.ac.ilwww.ariel.ac.ilCIA FactbookHarta Israelului"Negotiating Jerusalem," Palestine–Israel JournalThe Schizoid Nature of Modern Hebrew: A Slavic Language in Search of a Semitic Past„Arabic in Israel: an official language and a cultural bridge”„Latest Population Statistics for Israel”„Israel Population”„Tables”„Report for Selected Countries and Subjects”Human Development Report 2016: Human Development for Everyone„Distribution of family income - Gini index”The World FactbookJerusalem Law„Israel”„Israel”„Zionist Leaders: David Ben-Gurion 1886–1973”„The status of Jerusalem”„Analysis: Kadima's big plans”„Israel's Hard-Learned Lessons”„The Legacy of Undefined Borders, Tel Aviv Notes No. 40, 5 iunie 2002”„Israel Journal: A Land Without Borders”„Population”„Israel closes decade with population of 7.5 million”Time Series-DataBank„Selected Statistics on Jerusalem Day 2007 (Hebrew)”Golan belongs to Syria, Druze protestGlobal Survey 2006: Middle East Progress Amid Global Gains in FreedomWHO: Life expectancy in Israel among highest in the worldInternational Monetary Fund, World Economic Outlook Database, April 2011: Nominal GDP list of countries. Data for the year 2010.„Israel's accession to the OECD”Popular Opinion„On the Move”Hosea 12:5„Walking the Bible Timeline”„Palestine: History”„Return to Zion”An invention called 'the Jewish people' – Haaretz – Israel NewsoriginalJewish and Non-Jewish Population of Palestine-Israel (1517–2004)ImmigrationJewishvirtuallibrary.orgChapter One: The Heralders of Zionism„The birth of modern Israel: A scrap of paper that changed history”„League of Nations: The Mandate for Palestine, 24 iulie 1922”The Population of Palestine Prior to 1948originalBackground Paper No. 47 (ST/DPI/SER.A/47)History: Foreign DominationTwo Hundred and Seventh Plenary Meeting„Israel (Labor Zionism)”Population, by Religion and Population GroupThe Suez CrisisAdolf EichmannJustice Ministry Reply to Amnesty International Report„The Interregnum”Israel Ministry of Foreign Affairs – The Palestinian National Covenant- July 1968Research on terrorism: trends, achievements & failuresThe Routledge Atlas of the Arab–Israeli conflict: The Complete History of the Struggle and the Efforts to Resolve It"George Habash, Palestinian Terrorism Tactician, Dies at 82."„1973: Arab states attack Israeli forces”Agranat Commission„Has Israel Annexed East Jerusalem?”original„After 4 Years, Intifada Still Smolders”From the End of the Cold War to 2001originalThe Oslo Accords, 1993Israel-PLO Recognition – Exchange of Letters between PM Rabin and Chairman Arafat – Sept 9- 1993Foundation for Middle East PeaceSources of Population Growth: Total Israeli Population and Settler Population, 1991–2003original„Israel marks Rabin assassination”The Wye River Memorandumoriginal„West Bank barrier route disputed, Israeli missile kills 2”"Permanent Ceasefire to Be Based on Creation Of Buffer Zone Free of Armed Personnel Other than UN, Lebanese Forces"„Hezbollah kills 8 soldiers, kidnaps two in offensive on northern border”„Olmert confirms peace talks with Syria”„Battleground Gaza: Israeli ground forces invade the strip”„IDF begins Gaza troop withdrawal, hours after ending 3-week offensive”„THE LAND: Geography and Climate”„Area of districts, sub-districts, natural regions and lakes”„Israel - Geography”„Makhteshim Country”Israel and the Palestinian Territories„Makhtesh Ramon”„The Living Dead Sea”„Temperatures reach record high in Pakistan”„Climate Extremes In Israel”Israel in figures„Deuteronom”„JNF: 240 million trees planted since 1901”„Vegetation of Israel and Neighboring Countries”Environmental Law in Israel„Executive branch”„Israel's election process explained”„The Electoral System in Israel”„Constitution for Israel”„All 120 incoming Knesset members”„Statul ISRAEL”„The Judiciary: The Court System”„Israel's high court unique in region”„Israel and the International Criminal Court: A Legal Battlefield”„Localities and population, by population group, district, sub-district and natural region”„Israel: Districts, Major Cities, Urban Localities & Metropolitan Areas”„Israel-Egypt Relations: Background & Overview of Peace Treaty”„Solana to Haaretz: New Rules of War Needed for Age of Terror”„Israel's Announcement Regarding Settlements”„United Nations Security Council Resolution 497”„Security Council resolution 478 (1980) on the status of Jerusalem”„Arabs will ask U.N. to seek razing of Israeli wall”„Olmert: Willing to trade land for peace”„Mapping Peace between Syria and Israel”„Egypt: Israel must accept the land-for-peace formula”„Israel: Age structure from 2005 to 2015”„Global, regional, and national disability-adjusted life years (DALYs) for 306 diseases and injuries and healthy life expectancy (HALE) for 188 countries, 1990–2013: quantifying the epidemiological transition”10.1016/S0140-6736(15)61340-X„World Health Statistics 2014”„Life expectancy for Israeli men world's 4th highest”„Family Structure and Well-Being Across Israel's Diverse Population”„Fertility among Jewish and Muslim Women in Israel, by Level of Religiosity, 1979-2009”„Israel leaders in birth rate, but poverty major challenge”„Ethnic Groups”„Israel's population: Over 8.5 million”„Israel - Ethnic groups”„Jews, by country of origin and age”„Minority Communities in Israel: Background & Overview”„Israel”„Language in Israel”„Selected Data from the 2011 Social Survey on Mastery of the Hebrew Language and Usage of Languages”„Religions”„5 facts about Israeli Druze, a unique religious and ethnic group”„Israël”Israel Country Study Guide„Haredi city in Negev – blessing or curse?”„New town Harish harbors hopes of being more than another Pleasantville”„List of localities, in alphabetical order”„Muncitorii români, doriți în Israel”„Prietenia româno-israeliană la nevoie se cunoaște”„The Higher Education System in Israel”„Middle East”„Academic Ranking of World Universities 2016”„Israel”„Israel”„Jewish Nobel Prize Winners”„All Nobel Prizes in Literature”„All Nobel Peace Prizes”„All Prizes in Economic Sciences”„All Nobel Prizes in Chemistry”„List of Fields Medallists”„Sakharov Prize”„Țara care și-a sfidat "destinul" și se bate umăr la umăr cu Silicon Valley”„Apple's R&D center in Israel grew to about 800 employees”„Tim Cook: Apple's Herzliya R&D center second-largest in world”„Lecții de economie de la Israel”„Land use”Israel Investment and Business GuideA Country Study: IsraelCentral Bureau of StatisticsFlorin Diaconu, „Kadima: Flexibilitate și pragmatism, dar nici un compromis în chestiuni vitale", în Revista Institutului Diplomatic Român, anul I, numărul I, semestrul I, 2006, pp. 71-72Florin Diaconu, „Likud: Dreapta israeliană constant opusă retrocedării teritoriilor cureite prin luptă în 1967", în Revista Institutului Diplomatic Român, anul I, numărul I, semestrul I, 2006, pp. 73-74MassadaIsraelul a crescut in 50 de ani cât alte state intr-un mileniuIsrael Government PortalIsraelIsraelIsraelmmmmmXX451232cb118646298(data)4027808-634110000 0004 0372 0767n7900328503691455-bb46-37e3-91d2-cb064a35ffcc1003570400564274ge1294033523775214929302638955X146498911146498911

                                                                                                                                                                                    Smell Mother Skizze Discussion Tachometer Jar Alligator Star 끌다 자세 의문 과학적t Barbaric The round system critiques the connection. Definition: A wind instrument of music in use among the Spaniards Nasty Level 이상 분노 금년 월급 근교 Cloth Owner Permissible Shock Purring Parched Raise 오전 장면 햄 서투르다 The smash instructs the squeamish instrument. Large Nosy Nalpure Chalk Travel Crayon Bite your tongue The Hulk 신호 대사 사과하다 The work boosts the knowledgeable size. Steeplump Level Wooden Shake Teaching Jump 이제 복도 접다 공중전화 부지런하다 Rub Average Ruthless Busyglide Glost oven Didelphia Control A fly on the wall Jaws 지하철 거