Print coordinates of an NxN grid











up vote
3
down vote

favorite












Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted



Input: N (integer)



Output: for N=3, a 3x3 grid:



0,0
1,0
2,0
0,1
1,1
2,1
0,2
1,2
2,2









share|improve this question









New contributor




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
















  • 3




    Welcome to PPCG! This is the start of a good question. I couldn't find a duplicate from a quick search, though I might be mistaken. One thing I'd suggest is to specify the input and output. I assume that the input is an integer N. Is the output a list of tuples, a list of strings, should it be printed? Does it need to be separated by a comma?
    – maxb
    3 hours ago






  • 4




    Are we allowed to return a list instead of printing them? Is any order acceptable (i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]] instead of what you have above)? Can the output have 1-indexed coordinates instead of 0-indexed?
    – Kevin Cruijssen
    2 hours ago






  • 1




    Can we start at (1,1) instead of (0,0) ?
    – sergiol
    2 hours ago






  • 4




    Is there a particular order they have to be in or is any order fine?
    – Post Left Garf Hunter
    2 hours ago






  • 2




    Possible duplicate of Cartesian product of a list with itself n times
    – Xcali
    19 mins ago















up vote
3
down vote

favorite












Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted



Input: N (integer)



Output: for N=3, a 3x3 grid:



0,0
1,0
2,0
0,1
1,1
2,1
0,2
1,2
2,2









share|improve this question









New contributor




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
















  • 3




    Welcome to PPCG! This is the start of a good question. I couldn't find a duplicate from a quick search, though I might be mistaken. One thing I'd suggest is to specify the input and output. I assume that the input is an integer N. Is the output a list of tuples, a list of strings, should it be printed? Does it need to be separated by a comma?
    – maxb
    3 hours ago






  • 4




    Are we allowed to return a list instead of printing them? Is any order acceptable (i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]] instead of what you have above)? Can the output have 1-indexed coordinates instead of 0-indexed?
    – Kevin Cruijssen
    2 hours ago






  • 1




    Can we start at (1,1) instead of (0,0) ?
    – sergiol
    2 hours ago






  • 4




    Is there a particular order they have to be in or is any order fine?
    – Post Left Garf Hunter
    2 hours ago






  • 2




    Possible duplicate of Cartesian product of a list with itself n times
    – Xcali
    19 mins ago













up vote
3
down vote

favorite









up vote
3
down vote

favorite











Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted



Input: N (integer)



Output: for N=3, a 3x3 grid:



0,0
1,0
2,0
0,1
1,1
2,1
0,2
1,2
2,2









share|improve this question









New contributor




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











Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted



Input: N (integer)



Output: for N=3, a 3x3 grid:



0,0
1,0
2,0
0,1
1,1
2,1
0,2
1,2
2,2






code-golf grid






share|improve this question









New contributor




Chris Puglia 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 question









New contributor




Chris Puglia 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 question




share|improve this question








edited 2 hours ago





















New contributor




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









asked 3 hours ago









Chris Puglia

222




222




New contributor




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





New contributor





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






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








  • 3




    Welcome to PPCG! This is the start of a good question. I couldn't find a duplicate from a quick search, though I might be mistaken. One thing I'd suggest is to specify the input and output. I assume that the input is an integer N. Is the output a list of tuples, a list of strings, should it be printed? Does it need to be separated by a comma?
    – maxb
    3 hours ago






  • 4




    Are we allowed to return a list instead of printing them? Is any order acceptable (i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]] instead of what you have above)? Can the output have 1-indexed coordinates instead of 0-indexed?
    – Kevin Cruijssen
    2 hours ago






  • 1




    Can we start at (1,1) instead of (0,0) ?
    – sergiol
    2 hours ago






  • 4




    Is there a particular order they have to be in or is any order fine?
    – Post Left Garf Hunter
    2 hours ago






  • 2




    Possible duplicate of Cartesian product of a list with itself n times
    – Xcali
    19 mins ago














  • 3




    Welcome to PPCG! This is the start of a good question. I couldn't find a duplicate from a quick search, though I might be mistaken. One thing I'd suggest is to specify the input and output. I assume that the input is an integer N. Is the output a list of tuples, a list of strings, should it be printed? Does it need to be separated by a comma?
    – maxb
    3 hours ago






  • 4




    Are we allowed to return a list instead of printing them? Is any order acceptable (i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]] instead of what you have above)? Can the output have 1-indexed coordinates instead of 0-indexed?
    – Kevin Cruijssen
    2 hours ago






  • 1




    Can we start at (1,1) instead of (0,0) ?
    – sergiol
    2 hours ago






  • 4




    Is there a particular order they have to be in or is any order fine?
    – Post Left Garf Hunter
    2 hours ago






  • 2




    Possible duplicate of Cartesian product of a list with itself n times
    – Xcali
    19 mins ago








3




3




Welcome to PPCG! This is the start of a good question. I couldn't find a duplicate from a quick search, though I might be mistaken. One thing I'd suggest is to specify the input and output. I assume that the input is an integer N. Is the output a list of tuples, a list of strings, should it be printed? Does it need to be separated by a comma?
– maxb
3 hours ago




Welcome to PPCG! This is the start of a good question. I couldn't find a duplicate from a quick search, though I might be mistaken. One thing I'd suggest is to specify the input and output. I assume that the input is an integer N. Is the output a list of tuples, a list of strings, should it be printed? Does it need to be separated by a comma?
– maxb
3 hours ago




4




4




Are we allowed to return a list instead of printing them? Is any order acceptable (i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]] instead of what you have above)? Can the output have 1-indexed coordinates instead of 0-indexed?
– Kevin Cruijssen
2 hours ago




Are we allowed to return a list instead of printing them? Is any order acceptable (i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]] instead of what you have above)? Can the output have 1-indexed coordinates instead of 0-indexed?
– Kevin Cruijssen
2 hours ago




1




1




Can we start at (1,1) instead of (0,0) ?
– sergiol
2 hours ago




Can we start at (1,1) instead of (0,0) ?
– sergiol
2 hours ago




4




4




Is there a particular order they have to be in or is any order fine?
– Post Left Garf Hunter
2 hours ago




Is there a particular order they have to be in or is any order fine?
– Post Left Garf Hunter
2 hours ago




2




2




Possible duplicate of Cartesian product of a list with itself n times
– Xcali
19 mins ago




Possible duplicate of Cartesian product of a list with itself n times
– Xcali
19 mins ago










17 Answers
17






active

oldest

votes

















up vote
6
down vote













Japt, 3 bytes



o ï


Test it here






share|improve this answer





















  • I had the same solution with ` ñÌ` at the end to sort it. Hopefully the OP doesn't care about the order.
    – Oliver
    2 hours ago




















up vote
4
down vote














R, 33 25 bytes





which(diag(scan())|1,T)-1


Try it online!



Thanks to Kirill L. for suggesting a 2-byte golf, which inspired me to look further :-)






share|improve this answer























  • Where do you hear about all of these functions in R? I've never even used arrayInd before, but I feel like it could be useful in a lot of things!
    – Sumner18
    2 hours ago










  • @Sumner18 You can't be as golfy if you don't understand a big chunk of the language, so it pays to read the docs! there are a few workhorse functions like match and which. which in particular has an arr.ind argument, so looking at the documentation for which, we see a note in the Details under .dimnames about passing to the arrayInd function!
    – Giuseppe
    2 hours ago










  • 31 bytes. Sadly, requires !!, as otherwise: argument to 'which' is not logical...
    – Kirill L.
    1 hour ago










  • @KirillL. that's neat! It also inspired me to shave off another 2 bytes. EDIT: another 6 bytes!
    – Giuseppe
    1 hour ago




















up vote
3
down vote














C (gcc), 83 51 bytes



Saved 32 bytes thanks to Kevin Cruijssen.





i;f(n){for(i=0;i<n*n;)printf("%d,%dn",i++/n,i%n);}


Try it online!



I'm by no means a C programmer (or C golfer), but I thought I'd give it a try. Should the main be included in the byte count?






share|improve this answer























  • 51 bytes :) (And no, main method doesn't have to be included. For Java, C, C#, etc. etc. we allows functions instead of full programs, since full programs are quite verbose and doesn't add anything to the actual solution.)
    – Kevin Cruijssen
    2 hours ago




















up vote
3
down vote














PowerShell, 48 42 bytes





param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}


Try it online!



Boring double-for loop.



Saved 6 bytes thanks to mazzy.






share|improve this answer























  • ? param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}
    – mazzy
    36 mins ago










  • @mazzy Of course, removing the -join. Thanks!
    – AdmBorkBork
    29 mins ago


















up vote
3
down vote














05AB1E, 8 bytes



L<ãí',ý»


Exactly as the challenge description: prints the 0-indexed coordinates ordered by y-then-x comma- and newline-delimited to STDOUT.



Try it online.



Explanation:





L          # Create a list in the range [1, (implicit) input]
# i.e. 3 → [1,2,3]
< # Decrease each by 1 to make the range [0, input)
# i.e. [1,2,3] → [0,1,2]
ã # Create each possible pair with itself
# i.e. [0,1,2] → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
í # Reverse each pair so they're sorted by y-then-x instead of x-then-y
# i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
# → [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
',ý '# Join each pair with a space delimiter
# i.e. [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
# → ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
» # And then join everything with a newline delimiter (and output implicitly)
# i.e. ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
# → "0,0n1,0n2,0n0,1n1,1n2,1n0,2n1,2n2,2"







05AB1E, 2 bytes






Returns a list of 1-indexed coordinates ordered by x-then-y.



Try it online.



Explanation:





L     # Create a list in the range [1, (implicit) input]
# i.e. 3 → [1,2,3]
ã # Create each possible pair with itself (and output implicitly)
# i.e. [1,2,3] → [[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]]





share|improve this answer























  • How comes that your 2-byter is 1-indexed?
    – maxb
    2 hours ago










  • @maxb L is a 1-indexed list in the range [1,n] (where n is the implicit input). But I'll add an explanation for both when I get home. G2g now to avoid traffic jams (as much as possible..)
    – Kevin Cruijssen
    2 hours ago


















up vote
2
down vote














Tcl, 70 bytes



proc C {n i 0} {time {set j 0
time {puts $i,$j
incr j} $n
incr i} $n}


Try it online!






share|improve this answer























  • Failed outgolf: tio.run/##K0nO@f@/oCg/…
    – sergiol
    2 hours ago


















up vote
1
down vote














Python 2, 39 bytes





lambda n:[(i%n,i/n)for i in range(n*n)]


Try it online!






share|improve this answer























  • I think the question requires variable N...
    – Felix Palmen
    2 hours ago










  • @FelixPalmen Doh.. Fixed :)
    – TFeld
    2 hours ago


















up vote
1
down vote













Pyth, 4 bytes



^UQ2


Full program. Outputs list of coordinate pairs.



^UQ2   Implicit: Q=eval(input())
UQ [0-Q)
^ 2 Take the cartesian product of the previous result with itself





share|improve this answer




























    up vote
    1
    down vote














    MathGolf, 2 bytes



    r■


    Try it online!



    Explanation



    r    Range(0, n)
    ■ Cartesian product with self for lists


    For pretty-printing, you could add n to have it print one list item per line.






    share|improve this answer




























      up vote
      1
      down vote













      APL+WIN, 11 bytes



      (⍳n)∘.,⍳n←⎕


      Index origin = 0. Prompts for input for n and outputs the following for n=4:



      0 0  0 1  0 2  0 3
      1 0 1 1 1 2 1 3
      2 0 2 1 2 2 2 3
      3 0 3 1 3 2 3 3





      share|improve this answer




























        up vote
        0
        down vote














        Lua, 63 bytes





        s=io.read()-1 for i=0,s do for j=0,s do print(i..','..j)end end


        Try it online!






        share|improve this answer






























          up vote
          0
          down vote














          Pepe, 88 bytes



          I've never done 2D iterating in Pepe before and it doesn't seem to work pretty well due to labels being dynamic. There's quite a lot of two byte commands to avoid moving the pointer.



          REREeErEErerErEReREErEEEErreEEreeeEeEEeerEEeerreEErEEEEEreeEReererEEEEErERRREEEEEeRrEree


          Try it online!



          Warning: Do not run it with input below 1 - it will kill your browser.






          share|improve this answer




























            up vote
            0
            down vote














            Perl 5 -na, 35 bytes





            map{//;say"$',$_"for 0..$F[0]}0..$_


            Try it online!






            share|improve this answer




























              up vote
              0
              down vote













              Powershell, 43 bytes





              param($n)$i--..--$n*++$n|%{$i+=!$_;"$i,$_"}


              Explanation:



              One row 0..$n-1 repeated $n times.






              share|improve this answer




























                up vote
                0
                down vote













                Pure Bash (no external utilities), 35





                eval echo {0..$[$1-1]},{0..$[$1-1]}


                Try it online!





                share




























                  up vote
                  0
                  down vote













                  Perl5, -42- 38 bytes



                  for$i(0..--$n){for(0..$n){say"$i,$_"}}


                  (The inner loop saves a few bytes by using the implicit variable "$_" as an index.)






                  share|improve this answer










                  New contributor




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

























                    up vote
                    0
                    down vote













                    C#, 59



                    First time posting. Apologies if I do something wrong!



                    Input: l



                    for(var j=0;j<l*l;j++)Console.Write($"{j%l},{(int)j/l}n");



                    Tested under VS2017 Pro





                    share








                    New contributor




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


















                      Your Answer





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

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

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

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

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


                      }
                      });






                      Chris Puglia is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177442%2fprint-coordinates-of-an-nxn-grid%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown

























                      17 Answers
                      17






                      active

                      oldest

                      votes








                      17 Answers
                      17






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes








                      up vote
                      6
                      down vote













                      Japt, 3 bytes



                      o ï


                      Test it here






                      share|improve this answer





















                      • I had the same solution with ` ñÌ` at the end to sort it. Hopefully the OP doesn't care about the order.
                        – Oliver
                        2 hours ago

















                      up vote
                      6
                      down vote













                      Japt, 3 bytes



                      o ï


                      Test it here






                      share|improve this answer





















                      • I had the same solution with ` ñÌ` at the end to sort it. Hopefully the OP doesn't care about the order.
                        – Oliver
                        2 hours ago















                      up vote
                      6
                      down vote










                      up vote
                      6
                      down vote









                      Japt, 3 bytes



                      o ï


                      Test it here






                      share|improve this answer












                      Japt, 3 bytes



                      o ï


                      Test it here







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 2 hours ago









                      Shaggy

                      18.6k21663




                      18.6k21663












                      • I had the same solution with ` ñÌ` at the end to sort it. Hopefully the OP doesn't care about the order.
                        – Oliver
                        2 hours ago




















                      • I had the same solution with ` ñÌ` at the end to sort it. Hopefully the OP doesn't care about the order.
                        – Oliver
                        2 hours ago


















                      I had the same solution with ` ñÌ` at the end to sort it. Hopefully the OP doesn't care about the order.
                      – Oliver
                      2 hours ago






                      I had the same solution with ` ñÌ` at the end to sort it. Hopefully the OP doesn't care about the order.
                      – Oliver
                      2 hours ago












                      up vote
                      4
                      down vote














                      R, 33 25 bytes





                      which(diag(scan())|1,T)-1


                      Try it online!



                      Thanks to Kirill L. for suggesting a 2-byte golf, which inspired me to look further :-)






                      share|improve this answer























                      • Where do you hear about all of these functions in R? I've never even used arrayInd before, but I feel like it could be useful in a lot of things!
                        – Sumner18
                        2 hours ago










                      • @Sumner18 You can't be as golfy if you don't understand a big chunk of the language, so it pays to read the docs! there are a few workhorse functions like match and which. which in particular has an arr.ind argument, so looking at the documentation for which, we see a note in the Details under .dimnames about passing to the arrayInd function!
                        – Giuseppe
                        2 hours ago










                      • 31 bytes. Sadly, requires !!, as otherwise: argument to 'which' is not logical...
                        – Kirill L.
                        1 hour ago










                      • @KirillL. that's neat! It also inspired me to shave off another 2 bytes. EDIT: another 6 bytes!
                        – Giuseppe
                        1 hour ago

















                      up vote
                      4
                      down vote














                      R, 33 25 bytes





                      which(diag(scan())|1,T)-1


                      Try it online!



                      Thanks to Kirill L. for suggesting a 2-byte golf, which inspired me to look further :-)






                      share|improve this answer























                      • Where do you hear about all of these functions in R? I've never even used arrayInd before, but I feel like it could be useful in a lot of things!
                        – Sumner18
                        2 hours ago










                      • @Sumner18 You can't be as golfy if you don't understand a big chunk of the language, so it pays to read the docs! there are a few workhorse functions like match and which. which in particular has an arr.ind argument, so looking at the documentation for which, we see a note in the Details under .dimnames about passing to the arrayInd function!
                        – Giuseppe
                        2 hours ago










                      • 31 bytes. Sadly, requires !!, as otherwise: argument to 'which' is not logical...
                        – Kirill L.
                        1 hour ago










                      • @KirillL. that's neat! It also inspired me to shave off another 2 bytes. EDIT: another 6 bytes!
                        – Giuseppe
                        1 hour ago















                      up vote
                      4
                      down vote










                      up vote
                      4
                      down vote










                      R, 33 25 bytes





                      which(diag(scan())|1,T)-1


                      Try it online!



                      Thanks to Kirill L. for suggesting a 2-byte golf, which inspired me to look further :-)






                      share|improve this answer















                      R, 33 25 bytes





                      which(diag(scan())|1,T)-1


                      Try it online!



                      Thanks to Kirill L. for suggesting a 2-byte golf, which inspired me to look further :-)







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 1 hour ago

























                      answered 2 hours ago









                      Giuseppe

                      16.4k31052




                      16.4k31052












                      • Where do you hear about all of these functions in R? I've never even used arrayInd before, but I feel like it could be useful in a lot of things!
                        – Sumner18
                        2 hours ago










                      • @Sumner18 You can't be as golfy if you don't understand a big chunk of the language, so it pays to read the docs! there are a few workhorse functions like match and which. which in particular has an arr.ind argument, so looking at the documentation for which, we see a note in the Details under .dimnames about passing to the arrayInd function!
                        – Giuseppe
                        2 hours ago










                      • 31 bytes. Sadly, requires !!, as otherwise: argument to 'which' is not logical...
                        – Kirill L.
                        1 hour ago










                      • @KirillL. that's neat! It also inspired me to shave off another 2 bytes. EDIT: another 6 bytes!
                        – Giuseppe
                        1 hour ago




















                      • Where do you hear about all of these functions in R? I've never even used arrayInd before, but I feel like it could be useful in a lot of things!
                        – Sumner18
                        2 hours ago










                      • @Sumner18 You can't be as golfy if you don't understand a big chunk of the language, so it pays to read the docs! there are a few workhorse functions like match and which. which in particular has an arr.ind argument, so looking at the documentation for which, we see a note in the Details under .dimnames about passing to the arrayInd function!
                        – Giuseppe
                        2 hours ago










                      • 31 bytes. Sadly, requires !!, as otherwise: argument to 'which' is not logical...
                        – Kirill L.
                        1 hour ago










                      • @KirillL. that's neat! It also inspired me to shave off another 2 bytes. EDIT: another 6 bytes!
                        – Giuseppe
                        1 hour ago


















                      Where do you hear about all of these functions in R? I've never even used arrayInd before, but I feel like it could be useful in a lot of things!
                      – Sumner18
                      2 hours ago




                      Where do you hear about all of these functions in R? I've never even used arrayInd before, but I feel like it could be useful in a lot of things!
                      – Sumner18
                      2 hours ago












                      @Sumner18 You can't be as golfy if you don't understand a big chunk of the language, so it pays to read the docs! there are a few workhorse functions like match and which. which in particular has an arr.ind argument, so looking at the documentation for which, we see a note in the Details under .dimnames about passing to the arrayInd function!
                      – Giuseppe
                      2 hours ago




                      @Sumner18 You can't be as golfy if you don't understand a big chunk of the language, so it pays to read the docs! there are a few workhorse functions like match and which. which in particular has an arr.ind argument, so looking at the documentation for which, we see a note in the Details under .dimnames about passing to the arrayInd function!
                      – Giuseppe
                      2 hours ago












                      31 bytes. Sadly, requires !!, as otherwise: argument to 'which' is not logical...
                      – Kirill L.
                      1 hour ago




                      31 bytes. Sadly, requires !!, as otherwise: argument to 'which' is not logical...
                      – Kirill L.
                      1 hour ago












                      @KirillL. that's neat! It also inspired me to shave off another 2 bytes. EDIT: another 6 bytes!
                      – Giuseppe
                      1 hour ago






                      @KirillL. that's neat! It also inspired me to shave off another 2 bytes. EDIT: another 6 bytes!
                      – Giuseppe
                      1 hour ago












                      up vote
                      3
                      down vote














                      C (gcc), 83 51 bytes



                      Saved 32 bytes thanks to Kevin Cruijssen.





                      i;f(n){for(i=0;i<n*n;)printf("%d,%dn",i++/n,i%n);}


                      Try it online!



                      I'm by no means a C programmer (or C golfer), but I thought I'd give it a try. Should the main be included in the byte count?






                      share|improve this answer























                      • 51 bytes :) (And no, main method doesn't have to be included. For Java, C, C#, etc. etc. we allows functions instead of full programs, since full programs are quite verbose and doesn't add anything to the actual solution.)
                        – Kevin Cruijssen
                        2 hours ago

















                      up vote
                      3
                      down vote














                      C (gcc), 83 51 bytes



                      Saved 32 bytes thanks to Kevin Cruijssen.





                      i;f(n){for(i=0;i<n*n;)printf("%d,%dn",i++/n,i%n);}


                      Try it online!



                      I'm by no means a C programmer (or C golfer), but I thought I'd give it a try. Should the main be included in the byte count?






                      share|improve this answer























                      • 51 bytes :) (And no, main method doesn't have to be included. For Java, C, C#, etc. etc. we allows functions instead of full programs, since full programs are quite verbose and doesn't add anything to the actual solution.)
                        – Kevin Cruijssen
                        2 hours ago















                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote










                      C (gcc), 83 51 bytes



                      Saved 32 bytes thanks to Kevin Cruijssen.





                      i;f(n){for(i=0;i<n*n;)printf("%d,%dn",i++/n,i%n);}


                      Try it online!



                      I'm by no means a C programmer (or C golfer), but I thought I'd give it a try. Should the main be included in the byte count?






                      share|improve this answer















                      C (gcc), 83 51 bytes



                      Saved 32 bytes thanks to Kevin Cruijssen.





                      i;f(n){for(i=0;i<n*n;)printf("%d,%dn",i++/n,i%n);}


                      Try it online!



                      I'm by no means a C programmer (or C golfer), but I thought I'd give it a try. Should the main be included in the byte count?







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 2 hours ago

























                      answered 2 hours ago









                      maxb

                      2,5031927




                      2,5031927












                      • 51 bytes :) (And no, main method doesn't have to be included. For Java, C, C#, etc. etc. we allows functions instead of full programs, since full programs are quite verbose and doesn't add anything to the actual solution.)
                        – Kevin Cruijssen
                        2 hours ago




















                      • 51 bytes :) (And no, main method doesn't have to be included. For Java, C, C#, etc. etc. we allows functions instead of full programs, since full programs are quite verbose and doesn't add anything to the actual solution.)
                        – Kevin Cruijssen
                        2 hours ago


















                      51 bytes :) (And no, main method doesn't have to be included. For Java, C, C#, etc. etc. we allows functions instead of full programs, since full programs are quite verbose and doesn't add anything to the actual solution.)
                      – Kevin Cruijssen
                      2 hours ago






                      51 bytes :) (And no, main method doesn't have to be included. For Java, C, C#, etc. etc. we allows functions instead of full programs, since full programs are quite verbose and doesn't add anything to the actual solution.)
                      – Kevin Cruijssen
                      2 hours ago












                      up vote
                      3
                      down vote














                      PowerShell, 48 42 bytes





                      param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}


                      Try it online!



                      Boring double-for loop.



                      Saved 6 bytes thanks to mazzy.






                      share|improve this answer























                      • ? param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}
                        – mazzy
                        36 mins ago










                      • @mazzy Of course, removing the -join. Thanks!
                        – AdmBorkBork
                        29 mins ago















                      up vote
                      3
                      down vote














                      PowerShell, 48 42 bytes





                      param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}


                      Try it online!



                      Boring double-for loop.



                      Saved 6 bytes thanks to mazzy.






                      share|improve this answer























                      • ? param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}
                        – mazzy
                        36 mins ago










                      • @mazzy Of course, removing the -join. Thanks!
                        – AdmBorkBork
                        29 mins ago













                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote










                      PowerShell, 48 42 bytes





                      param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}


                      Try it online!



                      Boring double-for loop.



                      Saved 6 bytes thanks to mazzy.






                      share|improve this answer















                      PowerShell, 48 42 bytes





                      param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}


                      Try it online!



                      Boring double-for loop.



                      Saved 6 bytes thanks to mazzy.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 29 mins ago

























                      answered 1 hour ago









                      AdmBorkBork

                      26k364226




                      26k364226












                      • ? param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}
                        – mazzy
                        36 mins ago










                      • @mazzy Of course, removing the -join. Thanks!
                        – AdmBorkBork
                        29 mins ago


















                      • ? param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}
                        – mazzy
                        36 mins ago










                      • @mazzy Of course, removing the -join. Thanks!
                        – AdmBorkBork
                        29 mins ago
















                      ? param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}
                      – mazzy
                      36 mins ago




                      ? param($n)0..--$n|%{$i=$_;0..$n|%{"$i,$_"}}
                      – mazzy
                      36 mins ago












                      @mazzy Of course, removing the -join. Thanks!
                      – AdmBorkBork
                      29 mins ago




                      @mazzy Of course, removing the -join. Thanks!
                      – AdmBorkBork
                      29 mins ago










                      up vote
                      3
                      down vote














                      05AB1E, 8 bytes



                      L<ãí',ý»


                      Exactly as the challenge description: prints the 0-indexed coordinates ordered by y-then-x comma- and newline-delimited to STDOUT.



                      Try it online.



                      Explanation:





                      L          # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      < # Decrease each by 1 to make the range [0, input)
                      # i.e. [1,2,3] → [0,1,2]
                      ã # Create each possible pair with itself
                      # i.e. [0,1,2] → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      í # Reverse each pair so they're sorted by y-then-x instead of x-then-y
                      # i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      # → [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      ',ý '# Join each pair with a space delimiter
                      # i.e. [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      # → ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      » # And then join everything with a newline delimiter (and output implicitly)
                      # i.e. ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      # → "0,0n1,0n2,0n0,1n1,1n2,1n0,2n1,2n2,2"







                      05AB1E, 2 bytes






                      Returns a list of 1-indexed coordinates ordered by x-then-y.



                      Try it online.



                      Explanation:





                      L     # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      ã # Create each possible pair with itself (and output implicitly)
                      # i.e. [1,2,3] → [[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]]





                      share|improve this answer























                      • How comes that your 2-byter is 1-indexed?
                        – maxb
                        2 hours ago










                      • @maxb L is a 1-indexed list in the range [1,n] (where n is the implicit input). But I'll add an explanation for both when I get home. G2g now to avoid traffic jams (as much as possible..)
                        – Kevin Cruijssen
                        2 hours ago















                      up vote
                      3
                      down vote














                      05AB1E, 8 bytes



                      L<ãí',ý»


                      Exactly as the challenge description: prints the 0-indexed coordinates ordered by y-then-x comma- and newline-delimited to STDOUT.



                      Try it online.



                      Explanation:





                      L          # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      < # Decrease each by 1 to make the range [0, input)
                      # i.e. [1,2,3] → [0,1,2]
                      ã # Create each possible pair with itself
                      # i.e. [0,1,2] → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      í # Reverse each pair so they're sorted by y-then-x instead of x-then-y
                      # i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      # → [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      ',ý '# Join each pair with a space delimiter
                      # i.e. [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      # → ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      » # And then join everything with a newline delimiter (and output implicitly)
                      # i.e. ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      # → "0,0n1,0n2,0n0,1n1,1n2,1n0,2n1,2n2,2"







                      05AB1E, 2 bytes






                      Returns a list of 1-indexed coordinates ordered by x-then-y.



                      Try it online.



                      Explanation:





                      L     # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      ã # Create each possible pair with itself (and output implicitly)
                      # i.e. [1,2,3] → [[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]]





                      share|improve this answer























                      • How comes that your 2-byter is 1-indexed?
                        – maxb
                        2 hours ago










                      • @maxb L is a 1-indexed list in the range [1,n] (where n is the implicit input). But I'll add an explanation for both when I get home. G2g now to avoid traffic jams (as much as possible..)
                        – Kevin Cruijssen
                        2 hours ago













                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote










                      05AB1E, 8 bytes



                      L<ãí',ý»


                      Exactly as the challenge description: prints the 0-indexed coordinates ordered by y-then-x comma- and newline-delimited to STDOUT.



                      Try it online.



                      Explanation:





                      L          # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      < # Decrease each by 1 to make the range [0, input)
                      # i.e. [1,2,3] → [0,1,2]
                      ã # Create each possible pair with itself
                      # i.e. [0,1,2] → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      í # Reverse each pair so they're sorted by y-then-x instead of x-then-y
                      # i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      # → [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      ',ý '# Join each pair with a space delimiter
                      # i.e. [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      # → ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      » # And then join everything with a newline delimiter (and output implicitly)
                      # i.e. ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      # → "0,0n1,0n2,0n0,1n1,1n2,1n0,2n1,2n2,2"







                      05AB1E, 2 bytes






                      Returns a list of 1-indexed coordinates ordered by x-then-y.



                      Try it online.



                      Explanation:





                      L     # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      ã # Create each possible pair with itself (and output implicitly)
                      # i.e. [1,2,3] → [[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]]





                      share|improve this answer















                      05AB1E, 8 bytes



                      L<ãí',ý»


                      Exactly as the challenge description: prints the 0-indexed coordinates ordered by y-then-x comma- and newline-delimited to STDOUT.



                      Try it online.



                      Explanation:





                      L          # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      < # Decrease each by 1 to make the range [0, input)
                      # i.e. [1,2,3] → [0,1,2]
                      ã # Create each possible pair with itself
                      # i.e. [0,1,2] → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      í # Reverse each pair so they're sorted by y-then-x instead of x-then-y
                      # i.e. [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
                      # → [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      ',ý '# Join each pair with a space delimiter
                      # i.e. [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
                      # → ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      » # And then join everything with a newline delimiter (and output implicitly)
                      # i.e. ["0,0","1,0","2,0","0,1","1,1","2,1","0,2","1,2","2,2"]
                      # → "0,0n1,0n2,0n0,1n1,1n2,1n0,2n1,2n2,2"







                      05AB1E, 2 bytes






                      Returns a list of 1-indexed coordinates ordered by x-then-y.



                      Try it online.



                      Explanation:





                      L     # Create a list in the range [1, (implicit) input]
                      # i.e. 3 → [1,2,3]
                      ã # Create each possible pair with itself (and output implicitly)
                      # i.e. [1,2,3] → [[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]]






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 4 mins ago

























                      answered 2 hours ago









                      Kevin Cruijssen

                      35.2k554186




                      35.2k554186












                      • How comes that your 2-byter is 1-indexed?
                        – maxb
                        2 hours ago










                      • @maxb L is a 1-indexed list in the range [1,n] (where n is the implicit input). But I'll add an explanation for both when I get home. G2g now to avoid traffic jams (as much as possible..)
                        – Kevin Cruijssen
                        2 hours ago


















                      • How comes that your 2-byter is 1-indexed?
                        – maxb
                        2 hours ago










                      • @maxb L is a 1-indexed list in the range [1,n] (where n is the implicit input). But I'll add an explanation for both when I get home. G2g now to avoid traffic jams (as much as possible..)
                        – Kevin Cruijssen
                        2 hours ago
















                      How comes that your 2-byter is 1-indexed?
                      – maxb
                      2 hours ago




                      How comes that your 2-byter is 1-indexed?
                      – maxb
                      2 hours ago












                      @maxb L is a 1-indexed list in the range [1,n] (where n is the implicit input). But I'll add an explanation for both when I get home. G2g now to avoid traffic jams (as much as possible..)
                      – Kevin Cruijssen
                      2 hours ago




                      @maxb L is a 1-indexed list in the range [1,n] (where n is the implicit input). But I'll add an explanation for both when I get home. G2g now to avoid traffic jams (as much as possible..)
                      – Kevin Cruijssen
                      2 hours ago










                      up vote
                      2
                      down vote














                      Tcl, 70 bytes



                      proc C {n i 0} {time {set j 0
                      time {puts $i,$j
                      incr j} $n
                      incr i} $n}


                      Try it online!






                      share|improve this answer























                      • Failed outgolf: tio.run/##K0nO@f@/oCg/…
                        – sergiol
                        2 hours ago















                      up vote
                      2
                      down vote














                      Tcl, 70 bytes



                      proc C {n i 0} {time {set j 0
                      time {puts $i,$j
                      incr j} $n
                      incr i} $n}


                      Try it online!






                      share|improve this answer























                      • Failed outgolf: tio.run/##K0nO@f@/oCg/…
                        – sergiol
                        2 hours ago













                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote










                      Tcl, 70 bytes



                      proc C {n i 0} {time {set j 0
                      time {puts $i,$j
                      incr j} $n
                      incr i} $n}


                      Try it online!






                      share|improve this answer















                      Tcl, 70 bytes



                      proc C {n i 0} {time {set j 0
                      time {puts $i,$j
                      incr j} $n
                      incr i} $n}


                      Try it online!







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 2 hours ago

























                      answered 2 hours ago









                      sergiol

                      2,3321925




                      2,3321925












                      • Failed outgolf: tio.run/##K0nO@f@/oCg/…
                        – sergiol
                        2 hours ago


















                      • Failed outgolf: tio.run/##K0nO@f@/oCg/…
                        – sergiol
                        2 hours ago
















                      Failed outgolf: tio.run/##K0nO@f@/oCg/…
                      – sergiol
                      2 hours ago




                      Failed outgolf: tio.run/##K0nO@f@/oCg/…
                      – sergiol
                      2 hours ago










                      up vote
                      1
                      down vote














                      Python 2, 39 bytes





                      lambda n:[(i%n,i/n)for i in range(n*n)]


                      Try it online!






                      share|improve this answer























                      • I think the question requires variable N...
                        – Felix Palmen
                        2 hours ago










                      • @FelixPalmen Doh.. Fixed :)
                        – TFeld
                        2 hours ago















                      up vote
                      1
                      down vote














                      Python 2, 39 bytes





                      lambda n:[(i%n,i/n)for i in range(n*n)]


                      Try it online!






                      share|improve this answer























                      • I think the question requires variable N...
                        – Felix Palmen
                        2 hours ago










                      • @FelixPalmen Doh.. Fixed :)
                        – TFeld
                        2 hours ago













                      up vote
                      1
                      down vote










                      up vote
                      1
                      down vote










                      Python 2, 39 bytes





                      lambda n:[(i%n,i/n)for i in range(n*n)]


                      Try it online!






                      share|improve this answer















                      Python 2, 39 bytes





                      lambda n:[(i%n,i/n)for i in range(n*n)]


                      Try it online!







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 2 hours ago

























                      answered 2 hours ago









                      TFeld

                      14k21240




                      14k21240












                      • I think the question requires variable N...
                        – Felix Palmen
                        2 hours ago










                      • @FelixPalmen Doh.. Fixed :)
                        – TFeld
                        2 hours ago


















                      • I think the question requires variable N...
                        – Felix Palmen
                        2 hours ago










                      • @FelixPalmen Doh.. Fixed :)
                        – TFeld
                        2 hours ago
















                      I think the question requires variable N...
                      – Felix Palmen
                      2 hours ago




                      I think the question requires variable N...
                      – Felix Palmen
                      2 hours ago












                      @FelixPalmen Doh.. Fixed :)
                      – TFeld
                      2 hours ago




                      @FelixPalmen Doh.. Fixed :)
                      – TFeld
                      2 hours ago










                      up vote
                      1
                      down vote













                      Pyth, 4 bytes



                      ^UQ2


                      Full program. Outputs list of coordinate pairs.



                      ^UQ2   Implicit: Q=eval(input())
                      UQ [0-Q)
                      ^ 2 Take the cartesian product of the previous result with itself





                      share|improve this answer

























                        up vote
                        1
                        down vote













                        Pyth, 4 bytes



                        ^UQ2


                        Full program. Outputs list of coordinate pairs.



                        ^UQ2   Implicit: Q=eval(input())
                        UQ [0-Q)
                        ^ 2 Take the cartesian product of the previous result with itself





                        share|improve this answer























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          Pyth, 4 bytes



                          ^UQ2


                          Full program. Outputs list of coordinate pairs.



                          ^UQ2   Implicit: Q=eval(input())
                          UQ [0-Q)
                          ^ 2 Take the cartesian product of the previous result with itself





                          share|improve this answer












                          Pyth, 4 bytes



                          ^UQ2


                          Full program. Outputs list of coordinate pairs.



                          ^UQ2   Implicit: Q=eval(input())
                          UQ [0-Q)
                          ^ 2 Take the cartesian product of the previous result with itself






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 2 hours ago









                          Sok

                          3,459722




                          3,459722






















                              up vote
                              1
                              down vote














                              MathGolf, 2 bytes



                              r■


                              Try it online!



                              Explanation



                              r    Range(0, n)
                              ■ Cartesian product with self for lists


                              For pretty-printing, you could add n to have it print one list item per line.






                              share|improve this answer

























                                up vote
                                1
                                down vote














                                MathGolf, 2 bytes



                                r■


                                Try it online!



                                Explanation



                                r    Range(0, n)
                                ■ Cartesian product with self for lists


                                For pretty-printing, you could add n to have it print one list item per line.






                                share|improve this answer























                                  up vote
                                  1
                                  down vote










                                  up vote
                                  1
                                  down vote










                                  MathGolf, 2 bytes



                                  r■


                                  Try it online!



                                  Explanation



                                  r    Range(0, n)
                                  ■ Cartesian product with self for lists


                                  For pretty-printing, you could add n to have it print one list item per line.






                                  share|improve this answer













                                  MathGolf, 2 bytes



                                  r■


                                  Try it online!



                                  Explanation



                                  r    Range(0, n)
                                  ■ Cartesian product with self for lists


                                  For pretty-printing, you could add n to have it print one list item per line.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered 2 hours ago









                                  maxb

                                  2,5031927




                                  2,5031927






















                                      up vote
                                      1
                                      down vote













                                      APL+WIN, 11 bytes



                                      (⍳n)∘.,⍳n←⎕


                                      Index origin = 0. Prompts for input for n and outputs the following for n=4:



                                      0 0  0 1  0 2  0 3
                                      1 0 1 1 1 2 1 3
                                      2 0 2 1 2 2 2 3
                                      3 0 3 1 3 2 3 3





                                      share|improve this answer

























                                        up vote
                                        1
                                        down vote













                                        APL+WIN, 11 bytes



                                        (⍳n)∘.,⍳n←⎕


                                        Index origin = 0. Prompts for input for n and outputs the following for n=4:



                                        0 0  0 1  0 2  0 3
                                        1 0 1 1 1 2 1 3
                                        2 0 2 1 2 2 2 3
                                        3 0 3 1 3 2 3 3





                                        share|improve this answer























                                          up vote
                                          1
                                          down vote










                                          up vote
                                          1
                                          down vote









                                          APL+WIN, 11 bytes



                                          (⍳n)∘.,⍳n←⎕


                                          Index origin = 0. Prompts for input for n and outputs the following for n=4:



                                          0 0  0 1  0 2  0 3
                                          1 0 1 1 1 2 1 3
                                          2 0 2 1 2 2 2 3
                                          3 0 3 1 3 2 3 3





                                          share|improve this answer












                                          APL+WIN, 11 bytes



                                          (⍳n)∘.,⍳n←⎕


                                          Index origin = 0. Prompts for input for n and outputs the following for n=4:



                                          0 0  0 1  0 2  0 3
                                          1 0 1 1 1 2 1 3
                                          2 0 2 1 2 2 2 3
                                          3 0 3 1 3 2 3 3






                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered 2 hours ago









                                          Graham

                                          2,19678




                                          2,19678






















                                              up vote
                                              0
                                              down vote














                                              Lua, 63 bytes





                                              s=io.read()-1 for i=0,s do for j=0,s do print(i..','..j)end end


                                              Try it online!






                                              share|improve this answer



























                                                up vote
                                                0
                                                down vote














                                                Lua, 63 bytes





                                                s=io.read()-1 for i=0,s do for j=0,s do print(i..','..j)end end


                                                Try it online!






                                                share|improve this answer

























                                                  up vote
                                                  0
                                                  down vote










                                                  up vote
                                                  0
                                                  down vote










                                                  Lua, 63 bytes





                                                  s=io.read()-1 for i=0,s do for j=0,s do print(i..','..j)end end


                                                  Try it online!






                                                  share|improve this answer















                                                  Lua, 63 bytes





                                                  s=io.read()-1 for i=0,s do for j=0,s do print(i..','..j)end end


                                                  Try it online!







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 1 hour ago

























                                                  answered 1 hour ago









                                                  ouflak

                                                  193311




                                                  193311






















                                                      up vote
                                                      0
                                                      down vote














                                                      Pepe, 88 bytes



                                                      I've never done 2D iterating in Pepe before and it doesn't seem to work pretty well due to labels being dynamic. There's quite a lot of two byte commands to avoid moving the pointer.



                                                      REREeErEErerErEReREErEEEErreEEreeeEeEEeerEEeerreEErEEEEEreeEReererEEEEErERRREEEEEeRrEree


                                                      Try it online!



                                                      Warning: Do not run it with input below 1 - it will kill your browser.






                                                      share|improve this answer

























                                                        up vote
                                                        0
                                                        down vote














                                                        Pepe, 88 bytes



                                                        I've never done 2D iterating in Pepe before and it doesn't seem to work pretty well due to labels being dynamic. There's quite a lot of two byte commands to avoid moving the pointer.



                                                        REREeErEErerErEReREErEEEErreEEreeeEeEEeerEEeerreEErEEEEEreeEReererEEEEErERRREEEEEeRrEree


                                                        Try it online!



                                                        Warning: Do not run it with input below 1 - it will kill your browser.






                                                        share|improve this answer























                                                          up vote
                                                          0
                                                          down vote










                                                          up vote
                                                          0
                                                          down vote










                                                          Pepe, 88 bytes



                                                          I've never done 2D iterating in Pepe before and it doesn't seem to work pretty well due to labels being dynamic. There's quite a lot of two byte commands to avoid moving the pointer.



                                                          REREeErEErerErEReREErEEEErreEEreeeEeEEeerEEeerreEErEEEEEreeEReererEEEEErERRREEEEEeRrEree


                                                          Try it online!



                                                          Warning: Do not run it with input below 1 - it will kill your browser.






                                                          share|improve this answer













                                                          Pepe, 88 bytes



                                                          I've never done 2D iterating in Pepe before and it doesn't seem to work pretty well due to labels being dynamic. There's quite a lot of two byte commands to avoid moving the pointer.



                                                          REREeErEErerErEReREErEEEErreEEreeeEeEEeerEEeerreEErEEEEEreeEReererEEEEErERRREEEEEeRrEree


                                                          Try it online!



                                                          Warning: Do not run it with input below 1 - it will kill your browser.







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered 42 mins ago









                                                          RedClover

                                                          562523




                                                          562523






















                                                              up vote
                                                              0
                                                              down vote














                                                              Perl 5 -na, 35 bytes





                                                              map{//;say"$',$_"for 0..$F[0]}0..$_


                                                              Try it online!






                                                              share|improve this answer

























                                                                up vote
                                                                0
                                                                down vote














                                                                Perl 5 -na, 35 bytes





                                                                map{//;say"$',$_"for 0..$F[0]}0..$_


                                                                Try it online!






                                                                share|improve this answer























                                                                  up vote
                                                                  0
                                                                  down vote










                                                                  up vote
                                                                  0
                                                                  down vote










                                                                  Perl 5 -na, 35 bytes





                                                                  map{//;say"$',$_"for 0..$F[0]}0..$_


                                                                  Try it online!






                                                                  share|improve this answer













                                                                  Perl 5 -na, 35 bytes





                                                                  map{//;say"$',$_"for 0..$F[0]}0..$_


                                                                  Try it online!







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered 32 mins ago









                                                                  Xcali

                                                                  5,049520




                                                                  5,049520






















                                                                      up vote
                                                                      0
                                                                      down vote













                                                                      Powershell, 43 bytes





                                                                      param($n)$i--..--$n*++$n|%{$i+=!$_;"$i,$_"}


                                                                      Explanation:



                                                                      One row 0..$n-1 repeated $n times.






                                                                      share|improve this answer

























                                                                        up vote
                                                                        0
                                                                        down vote













                                                                        Powershell, 43 bytes





                                                                        param($n)$i--..--$n*++$n|%{$i+=!$_;"$i,$_"}


                                                                        Explanation:



                                                                        One row 0..$n-1 repeated $n times.






                                                                        share|improve this answer























                                                                          up vote
                                                                          0
                                                                          down vote










                                                                          up vote
                                                                          0
                                                                          down vote









                                                                          Powershell, 43 bytes





                                                                          param($n)$i--..--$n*++$n|%{$i+=!$_;"$i,$_"}


                                                                          Explanation:



                                                                          One row 0..$n-1 repeated $n times.






                                                                          share|improve this answer












                                                                          Powershell, 43 bytes





                                                                          param($n)$i--..--$n*++$n|%{$i+=!$_;"$i,$_"}


                                                                          Explanation:



                                                                          One row 0..$n-1 repeated $n times.







                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered 28 mins ago









                                                                          mazzy

                                                                          1,975314




                                                                          1,975314






















                                                                              up vote
                                                                              0
                                                                              down vote













                                                                              Pure Bash (no external utilities), 35





                                                                              eval echo {0..$[$1-1]},{0..$[$1-1]}


                                                                              Try it online!





                                                                              share

























                                                                                up vote
                                                                                0
                                                                                down vote













                                                                                Pure Bash (no external utilities), 35





                                                                                eval echo {0..$[$1-1]},{0..$[$1-1]}


                                                                                Try it online!





                                                                                share























                                                                                  up vote
                                                                                  0
                                                                                  down vote










                                                                                  up vote
                                                                                  0
                                                                                  down vote









                                                                                  Pure Bash (no external utilities), 35





                                                                                  eval echo {0..$[$1-1]},{0..$[$1-1]}


                                                                                  Try it online!





                                                                                  share












                                                                                  Pure Bash (no external utilities), 35





                                                                                  eval echo {0..$[$1-1]},{0..$[$1-1]}


                                                                                  Try it online!






                                                                                  share











                                                                                  share


                                                                                  share










                                                                                  answered 9 mins ago









                                                                                  Digital Trauma

                                                                                  58.4k786220




                                                                                  58.4k786220






















                                                                                      up vote
                                                                                      0
                                                                                      down vote













                                                                                      Perl5, -42- 38 bytes



                                                                                      for$i(0..--$n){for(0..$n){say"$i,$_"}}


                                                                                      (The inner loop saves a few bytes by using the implicit variable "$_" as an index.)






                                                                                      share|improve this answer










                                                                                      New contributor




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






















                                                                                        up vote
                                                                                        0
                                                                                        down vote













                                                                                        Perl5, -42- 38 bytes



                                                                                        for$i(0..--$n){for(0..$n){say"$i,$_"}}


                                                                                        (The inner loop saves a few bytes by using the implicit variable "$_" as an index.)






                                                                                        share|improve this answer










                                                                                        New contributor




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




















                                                                                          up vote
                                                                                          0
                                                                                          down vote










                                                                                          up vote
                                                                                          0
                                                                                          down vote









                                                                                          Perl5, -42- 38 bytes



                                                                                          for$i(0..--$n){for(0..$n){say"$i,$_"}}


                                                                                          (The inner loop saves a few bytes by using the implicit variable "$_" as an index.)






                                                                                          share|improve this answer










                                                                                          New contributor




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









                                                                                          Perl5, -42- 38 bytes



                                                                                          for$i(0..--$n){for(0..$n){say"$i,$_"}}


                                                                                          (The inner loop saves a few bytes by using the implicit variable "$_" as an index.)







                                                                                          share|improve this answer










                                                                                          New contributor




                                                                                          Tom Williams 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








                                                                                          edited 7 mins ago





















                                                                                          New contributor




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









                                                                                          answered 19 mins ago









                                                                                          Tom Williams

                                                                                          12




                                                                                          12




                                                                                          New contributor




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





                                                                                          New contributor





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






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






















                                                                                              up vote
                                                                                              0
                                                                                              down vote













                                                                                              C#, 59



                                                                                              First time posting. Apologies if I do something wrong!



                                                                                              Input: l



                                                                                              for(var j=0;j<l*l;j++)Console.Write($"{j%l},{(int)j/l}n");



                                                                                              Tested under VS2017 Pro





                                                                                              share








                                                                                              New contributor




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






















                                                                                                up vote
                                                                                                0
                                                                                                down vote













                                                                                                C#, 59



                                                                                                First time posting. Apologies if I do something wrong!



                                                                                                Input: l



                                                                                                for(var j=0;j<l*l;j++)Console.Write($"{j%l},{(int)j/l}n");



                                                                                                Tested under VS2017 Pro





                                                                                                share








                                                                                                New contributor




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




















                                                                                                  up vote
                                                                                                  0
                                                                                                  down vote










                                                                                                  up vote
                                                                                                  0
                                                                                                  down vote









                                                                                                  C#, 59



                                                                                                  First time posting. Apologies if I do something wrong!



                                                                                                  Input: l



                                                                                                  for(var j=0;j<l*l;j++)Console.Write($"{j%l},{(int)j/l}n");



                                                                                                  Tested under VS2017 Pro





                                                                                                  share








                                                                                                  New contributor




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









                                                                                                  C#, 59



                                                                                                  First time posting. Apologies if I do something wrong!



                                                                                                  Input: l



                                                                                                  for(var j=0;j<l*l;j++)Console.Write($"{j%l},{(int)j/l}n");



                                                                                                  Tested under VS2017 Pro






                                                                                                  share








                                                                                                  New contributor




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








                                                                                                  share


                                                                                                  share






                                                                                                  New contributor




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









                                                                                                  answered 7 mins ago









                                                                                                  Destroigo

                                                                                                  1




                                                                                                  1




                                                                                                  New contributor




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





                                                                                                  New contributor





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






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






















                                                                                                      Chris Puglia is a new contributor. Be nice, and check out our Code of Conduct.










                                                                                                      draft saved

                                                                                                      draft discarded


















                                                                                                      Chris Puglia is a new contributor. Be nice, and check out our Code of Conduct.













                                                                                                      Chris Puglia is a new contributor. Be nice, and check out our Code of Conduct.












                                                                                                      Chris Puglia is a new contributor. Be nice, and check out our Code of Conduct.
















                                                                                                      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).






                                                                                                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                                      Please pay close attention to the following guidance:


                                                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                                                      But avoid



                                                                                                      • Asking for help, clarification, or responding to other answers.

                                                                                                      • Making statements based on opinion; back them up with references or personal experience.


                                                                                                      To learn more, see our tips on writing great answers.




                                                                                                      draft saved


                                                                                                      draft discarded














                                                                                                      StackExchange.ready(
                                                                                                      function () {
                                                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177442%2fprint-coordinates-of-an-nxn-grid%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

                                                                                                      What visual should I use to simply compare current year value vs last year in Power BI desktop

                                                                                                      Alexandru Averescu

                                                                                                      Trompette piccolo