title: Print/Output the L-phabet

text:
# Question
Title: Print/Output the L-phabet
Inspired by George Gibson's Print a Tabula Recta.

You are to print/output this exact text:

```
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

(Yes, I typed that by hand)

You are allowed to use all lowercase instead of all uppercase.

However, your choice of case must be consistent throughout the whole text.

### Rules/Requirements

* Each submission should be either a full program or function. If it is a function, it must be runnable by only needing to add the function call to the bottom of the program. Anything else (e.g. headers in C), must be included.
* If it is possible, provide a link to a site where your program can be tested.
* Your program must not write anything to `STDERR`.
* Standard Loopholes are forbidden.
* Your program can output in any case, but it must be printed (not an array or similar).

### Scoring

Programs are scored according to bytes, in UTF-8 by default or a different character set of your choice.

Eventually, the answer with the least bytes will win.

## Submissions

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```
# Language Name, N bytes

```

where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:

```
# Ruby, <s>104</s> <s>101</s> 96 bytes

```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:

```
# Perl, 43 + 2 (-p flag) = 45 bytes

```

You can also make the language name a link which will then show up in the leaderboard snippet:

```
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

```

## Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

```
/* Configuration */

var QUESTION_ID = 87064; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
```

```
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
```

# Answer
> 66 votes
# Excel, 19,604 bytes

```
=CHAR(64+MAX(COLUMN(),ROW()))

```

Paste this formula in `A1`, then drag all over `A1:Z26`.

Byte count:

1. The formula is 27 bytes.
2. You need to copy it 26^2 times. 27\*26\*26=19604.
3. I and others thought the score should be lower because you don't really need to type the formula again and again. I now think it's irrelevant - we count the size of the program, not the work spent writing it.
4. For comparison - see this 28,187 chars JS answer \- obviously, someone generated it rather than typing all this, but it doesn't change its size.

# Answer
> 44 votes
# Vim, 43 bytes

```
:h<_↵jjYZZPqqlmaYp`ajyl:norm v0r♥"↵`ajq25@q

```

Here  represents Return (`0x0a`) and  represents Ctrl-R (`0x12`).

Not quite as short as my Tabula Recta answer, but…

# Answer
> 28 votes
# Jelly, 6 bytes

```
ØA»'j⁷

```

Try it here. If only I hadn’t been lazy yesterday and implemented that one-byte alternative to `j⁷` (join by newlines)…

```
ØA      The uppercase alphabet.
  »'    Table of max(x, y).
    j⁷  Join by newlines.

```

# Answer
> 19 votes
# Dyalog APL, 11 bytes

```
⎕A[∘.⌈⍨⍳26]

```

`A[`...`]` pick elements from the uppercase alphabet according to
`∘.⌈⍨` the maximum table of
`⍳26` the first 26 integers

TryAPL online!

# Answer
> 17 votes
# brainfuck, ~~103~~ ~~96~~ ~~95~~ ~~91~~ 87 bytes

```
+++++[>+++++>++<<-]>+[[<<<+>>>-]----[<+>----]<+<<[>+>+>+<<<-]>-]>>[[<.>-]>[.>>]<<[<]>>]

```

This uses Esolangs' brainfuck constant for 64. Try it online!

# Answer
> 17 votes
# ///, ~~141~~ ~~94~~ ~~92~~ 82 bytes

```
/:/\\\\A//#/:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z://:/\/a#
\/a\///A/#

```

Try it online: Demonstration

Quite a fun language.

### Explanation:

Shortend code to only print a 4x4 square:

```
/:/\\\\A//#/:b:c:d://:/\/a#
\/a\///A/#

```

The first replacement `/:/\\\\A/` replaces `:` with `\\A`. This gives:

```
/#/\\Ab\\Ac\\Ad\\A//\\A/\/a#
\/a\///A/#

```

Then `/#/\\Ab\\Ac\\Ad\\A//\\A/` replaces `#` with `\Ab\Ac\Ad\A`:

```
/\\A/\/a\Ab\Ac\Ad\A
\/a\///A/\Ab\Ac\Ad\A

```

Now `/\\A/\/a\Ab\Ac\Ad\A<newline>\/a\//` replaces each `\A` in the subsequent code by `/aAbAcAdA<newline>/a/`, so this results in:

```
/A//aAbAcAdA
/a/b/aAbAcAdA
/a/c/aAbAcAdA
/a/d/aAbAcAdA
/a/

```

Now the first part `/A//` removes all `A`s.

```
abcd
/a/b/abcd
/a/c/abcd
/a/d/abcd
/a/

```

The first five characters `abcd<newline>` get printed. The next command `/a/b/` replaces `a` by `b`, resulting in:

```
bbcd
/b/c/bbcd
/b/d/bbcd
/b/

```

Again the first five characters `bbcd<newline>` get printed. The next command `/b/c/` replaces `b` by `c`:

```
cccd
/c/d/cccd
/c/

```

Again the first five characters `cccd<newline>` get printed. The next command `/c/d/` replaces `c` by `d`:

```
dddd
/d/

```

The first five characters `dddd<newline>` get printed. And the next command `/d/` is incomplete and therefore does nothing.

# Answer
> 11 votes
# Wolfram Language (Mathematica), ~~69~~ ~~65~~ ~~57~~ 44 bytes

*Saved 8 bytes thanks to Martin Ender.
Saved 13 bytes thanks to att.*

```
Print@@@Array[Alphabet[][[Max@##]]&,{26,26}]

```

Try it online! Full program which prints to standard output.

# Answer
> 9 votes
## Retina, 41 bytes

Byte count assumes ISO 8859-1 encoding. The leading linefeed is significant.

```

26$*Z
{`^[^A].+
$&¶$&
}T0-2`L`_L`^(.)\1+

```

### Explanation

```

26$*Z

```

Set the string to 26 copies of `Z`. Then the `{...}` instruct Retina to perform the remaining two instructions in a loop until the string stops changing.

```
{`^[^A].+
$&¶$&

```

Duplicate the first line if it doesn't start with an `A`.

```
}T0-2`L`_L`^(.)\1+

```

This is a transliteration stage. It is only applied if the string starts with at least two copies of the same character. If so, all but the last of those characters are decremented. The decrementing happens by mapping `L` (upper case alphabet) to `_L` (blank followed by upper case alphabet). The "all but the last" is indicated by the limit `-2` which tells Retina only to transliterate all characters up to the second-to-last in the match.

Try it online!

# Answer
> 8 votes
## ///, 348 bytes

```
/|/\/\///v/NNN|u/MMM|t/LLL|s/WXYZ|r/OOO|q/KLMa|p/RRRR|o/QQQQ|n/PPPP|m/SSS|l/EFGc|k/RSTb|j/UUUU|i/TTTT|h/WWW|g/VVV|f/XXXX|e/ZZZZZ|d/YYYYY|c/HIJq|b/UVs
|a/NOPQk/ABCDlBBCDlCCCDlDDDDlEEEElFFFFFFGcGGGGGGGcHHHHHHHcIIIIIIIIIJqJJJJJJJJJJqKKKKKKKKKKqttttMauuuuMavvvvNarrrrrPQknnnnQkooooQkppppRkmmmmmmSTbiiiiibjjjjjbgggggggVs
hhhhhhhWs
ffffffYZ
dddddZ
eeeeeZ

```

Try it online!

I've used the same technique to build this as for my /// answer to the challenge this was based on. However, I had to fix the CJam script because it didn't correctly handle substrings that can overlap themselves.

# Answer
> 8 votes
# Haskell, 35 bytes

```
a=['A'..'Z']
unlines$(<$>a).max<$>a

```

# Answer
> 8 votes
# Python 2, 59 bytes

```
n=0;exec'print bytearray([n+65]*n+range(n+65,91));n+=1;'*26

```

Test it on Ideone.

# Answer
> 7 votes
## C#, 147 bytes

```
void e(){for(int i=0,j=97;i<26;i++,j++)Console.WriteLine(new string((char)j,i)+new string(Enumerable.Range(j,26-i).Select(n=>(char)n).ToArray()));}

```

*sometimes i wonder why im even trying*

*edit:* fixed it

Try it online

# Answer
> 7 votes
# Sesos, 25 bytes

```
0000000: 2829c0 756fc6 aecae2 aecd9c 39e09e 099c63 7d8e3d  ().uo.......9....c}.=
0000015: 65a7c0 39                                         e..9

```

Try it online! Check *Debug* to see the generated SBIN code.

### Sesos assembly

The binary file above has been generated by assembling the following SASM code.

```
add 26
jmp
    jmp
        rwd 1, add 1, rwd 1, add 1, fwd 2, sub 1
    jnz
    rwd 2, add 64
    jmp
        fwd 2, add 1, rwd 2, sub 1
    jnz
    fwd 1, sub 1
jnz
fwd 1
jmp
    jmp
        rwd 1, add 1, fwd 1, sub 1
    jnz
    nop
        rwd 1
    jnz
    fwd 1
    jmp
        put, add 1, fwd 1
    jnz
    fwd 1
    jmp
        put, fwd 1
    jnz
    add 10, put, get
    nop
        rwd 1
    jnz
    fwd 1
; jnz (implicit)

```

### How it works

We start by initializing the tape to `ABCDEFGHIJKLMNOPQRSTUVWXYZ`. This is as follows.

Write **26** to a cell, leaving the tape in the following state.

```
                                                       v
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 0

```

As long as the cell under the data head is non-zero, we do the following.

Copy the number to the two cells to the left and add **64** to the leftmost copy.

```
                                                   v
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90 26 0 0

```

Move the leftmost copy to the original location, then subtract **1** from the rightmost copy.

```
                                                     v
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 90 0

```

The process stops after **26** iterations, since the rightmost copy is **0** by then. We move a cell to the right, so the final state of the tape after the initialization is the following.

```
     v
0 0 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0

```

Now we're ready to generate the output, by repeating the following process until the cell under the data head is zero.

First, we move the content of the cell under the data head one unit to the left, then move left until the last cell with a non-zero content.

```
   v
0 65 0 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0

```

Now, we print all cells, starting with the one under the data head and moving right until we find a **0** cell, incrementing each printed cell after printing it. After printing `A`, the tape looks as follows.

```
     v
0 66 0 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0

```

Now we move right, again printing all cells until a **0** cell in encountered. After printing `BCDEFGHIJKLMNOPQRSTUVWXYZ`, the tape looks as follows.

```
                                                                                v
0 66 0 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0

```

Now, we write **10** to the current cell, print the corresponding character (linefeed) and zero the cell with a call to `get` on empty input, leaving the tape unchanged.

Finally, we move to the last non-zero to the left, preparing the tape for the next iteration.

```
        v
0 66 0 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0

```

The next iteration is similar. We first move **66** one cell to the left, print both **66** cells (`BB`) and increment them to **67**, then print the remaining non-zero cells to the right (`CDEFGHIJKLMNOPQRSTUVWXYZ`), and finally place the data head on **67**, leaving the tape as follows.

```
           v
0 66 66 0 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0

```

After **24** more iterations and after printing `ZZZZZZZZZZZZZZZZZZZZZZZZZZ` and a linefeed, the tapes is left in the following state.

```
                                                                                v
0 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 0 0

```

Moving the data head to the left to the next non-zero cell will leave it in its current position, so the cell under it is **0** and the loop terminates.

# Answer
> 7 votes
# J, 13 bytes

```
u:65+>./~i.26

```

Online interpreter.

### Explanation

```
u:65+>./~i.26
         i.26  generate [0 1 ... 25]
       /~      build a table...
     >.        ...of maximum
  65+          add 65 to each element
u:             convert to unicode

```

# Answer
> 7 votes
# R, 58 bytes

```
l=LETTERS;for(i in 1:26){l[2:i-1]=l[i];cat(l,"\n",sep="")}

```

Thanks to operator precedence, `2:i-1` is equivalent to `1:(i-1)`. Uses the built-in constant `LETTERS` that contains the alphabet in upper case. Everything else is rather self-explanatory.
Usage:

```
> l=LETTERS;for(i in 1:26){l[2:i-1]=l[i];cat(l,"\n",sep="")}
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

# Answer
> 6 votes
# Python 2, ~~76~~ ~~70~~ 68 bytes

```
a=range(65,91)
i=0
for c in a:a[:i]=[c]*i;i+=1;print'%c'*26%tuple(a)

```

Very similar to my answer to the linked question.

*Saved 2 bytes thanks to @xnor (again)!*

# Answer
> 6 votes
# Matlab / Octave, ~~43~~ 39 bytes

*1 byte removed thanks to @beaker's idea of using `[...,'']` to convert to char.*

```
@()[91-rot90(gallery('minij',26),2),'']

```

This is an anonymous function that returns a 2D char array.

**Try it on Ideone**.

### Explanation

`gallery('minij',...)` gives a matrix in which each entry equals the minimum of its row and column indices:

```
 1     1     1     1  ...
 1     2     2     2
 1     2     3     3
 1     2     3     4
 ...

```

This is rotated 180 degrees with `rot90(...,2)`:

```
26    25    24    23  ...
25    25    24    23
24    24    24    23
23    23    23    23
...

```

The `91-...` operation gives the ASCII codes of uppercase letters:

```
65    66    67    68
66    66    67    68
67    67    67    68
68    68    69    68 ...
...

```

Finally `[...,'']` concatenates horizontally with an empty string. This has the effect of converting to char.

# Answer
> 6 votes
## PowerShell v2+, ~~76~~ ~~52~~ 40 bytes

```
65..90|%{-join[char[]](,$_*$i+++$_..90)}

```

Loops from `65` to `89`. Each iteration, we're constructing an array using the comma-operator that consists of the current number `$_` multiplied by post-incremented helper variable `$i++`, concatenated with an array of the current number `$_` to `90`. That's encapsulated in a char-array cast, and `-join`ed together into a string. For example, for the first iteration, this array would be equivalent to `65..90`, or the whole alphabet. The second iteration would be `66+66..90`, or the whole alphabet with `B` repeated and no `A`.

Those are all left on the pipeline at program end (as an array), and printing to the console is implicit (the default `.ToString()` for an array is separated via newline, so we get that for free).

```
PS C:\Tools\Scripts\golfing> .\print-the-l-phabet.ps1
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

# Answer
> 6 votes
# , ~~42~~ 41 bytes

```
write(outer(L<-LETTERS,L,pmax),'',26,,'')

```

Try it online!

The next shortest R answer is still a bit too long since it prints out line by line. I was thinking about another question earlier today and realized a much shorter approach was possible for this one: I generate the matrix all at once using `outer` and `pmax` (parallel maximum) and then print it(\*) in one step with `write`.

(\*) technically, its transpose, but it's fortunately symmetric across its diagonal.

# Answer
> 5 votes
# MATL, 10 bytes

```
lY2t!2$X>c

```

**Online demo** (If you have issues with this interpreter, ping me in the MATL chat. Also, here is the TIO link in case you have issues)

**Explanation**

```
lY2     % Push an array of characters to the stack: 'AB...Z'
t!      % Duplicate and transpose
2$X>    % Take the element-wise maximum between these two (with expansion)
c       % Explicitly convert back to characters
        % Implicitly display the result.

```

# Answer
> 4 votes
# 05AB1E, 9 bytes

Code:

```
AAv¬N×?=¦

```

Explanation:

```
AA         # Push the alphabet twice.
  v        # For each in the alphabet.
   ¬       # Get the first character and
    N×     # multiply by the iteration variable.
      ?    # Pop and print.
       =   # Print the initial alphabet without popping.
        ¦  # Remove the first character of the initial alphabet and repeat.

```

Uses the **CP-1252** encoding. Try it online!.

# Answer
> 4 votes
# Javascript ES6, 81 bytes

```
x=>[...a='ABCDEFGHIJKLMNOPQRSTUVWXYZ'].map((x,y)=>x.repeat(y)+a.slice(y)).join`
`

```

Self-explanatory.

# Answer
> 4 votes
# Octave, 26 bytes

```
disp([max(L=65:90,L'),''])

```

Sample run on ideone.

# Answer
> 4 votes
# R, 56 bytes

Don't have the rep to comment, but @plannapus answer can be golfed-down a bit to:

```
for(i in 1:26)cat({L=LETTERS;L[1:i]=L[i];L},"\n",sep="")

```

resulting in the same output:

```
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

Though, if answer as a matrix is allowed (i.e. like here), we could do 49 bytes:

```
sapply(1:26,function(l){L=LETTERS;L[1:l]=L[l];L})

```

# Answer
> 4 votes
# Husk, 7 bytes

```
´ṪY…"AZ

```

Try it online! I'm rather surprised there isn't a Husk answer for this already. In any case, all this does is create a table () of the maximum (`Y`) of each pair of letters A to Z.

# Answer
> 3 votes
# Python 3, ~~71~~ 65 bytes

*Thanks to @LeakyNun for -6 bytes*

```
r=range(26)
for i in r:print(''.join(chr(max(i,x)+65)for x in r))

```

A full program that prints to STDOUT.

**How it works**

We assign character codes to the letters of the alphabet, from `0` for `A` to `25` for `Z`. The program loops over the interval `[0, 25]` with a line counter `i`, which determines the current character to be repeated and the length of the repeated section, and a character index `x`. By calling `max(i,x)`, all characters below the repeated character are clamped to the character code of the same. Adding `65` and calling `chr` converts the resultant character codes to their ASCII equivalents; `''.join` concatenates the characters, and each line is printed to STDOUT.

Try it on Ideone

# Answer
> 3 votes
## Haskell, ~~53~~ 46 bytes

```
unlines[(i<$['B'..i])++[i..'Z']|i<-['A'..'Z']]

```

Returns a single string with the L-phabet.

go through the chars `i` from `A` to `Z` and make a list of `(length ['B'..i])` copies of `i` followed by `[i..'Z']`. Join elements with newlines in-between.

# Answer
> 3 votes
# , 12 chars / 15 bytes

```
ᶐⓢ⒨Ċ_+ᶐč_)ü⬬

```

`Try it here (Chrome Canary only).`

Basically a port of my ES6 answer.

# Answer
> 3 votes
# Perl, 31 bytes

*-6 byte thanks to @Denis Ibaev*

```
say$_ x$A++,$_..Z for A..Z

```

Needs `-M5.010` to run. So run with :

```
perl -M5.010 -e 'say$_ x$A++,$_..Z for A..Z'

```

# Answer
> 3 votes
# Cheddar, 90 bytes

```
(|>26).map(i->String.letters.chars.map((j,k,l)->k<i?l[i]:j).fuse).vfuse.slice(1)

```

That `String.letters` is too long :/

Had to add a `.slice(1)` because leading newline is disallowed

## Explanation

```
(|>26)       // Range from [0, 26)
.map(i->     // Loop through that range
 String.letters.chars // Alphabet array
  .map(               // Loop through alphabet
  (j,k,l) ->          // j = letter, j = index, l = alphabet
    k<i?l[i]:j        // Basically `l[max(k,i)]`
  ).fuse     // Collapse the array
).vfuse      // Join on newlines

```

# Cheddar, 65 bytes (non-competing)

```
(|>26).map(i->String.letters.map((j,k,l)->k<i?l[i]:j).fuse).vfuse

```

Works with the nightly branch. Non-competing... sad part is that I already had the changes... just never commited ;\_;

# Answer
> 3 votes
# PHP, ~~75~~ 71 bytes

```
for($a=join(range(A,Z));$i<26;)printf("%'$a[$i]26s
",substr($a,$i++));

```

# Answer
> 3 votes
# R, 54 bytes

`v=L=LETTERS;for(i in 2:26){L[1:i]=L[i];v=cbind(v,L)};v`

This solution uses the **R** built-in constant `LETTERS`, that... well... lists the uppercase letters. There is also the constant `letters` for lowercase letters.

# Answer
> 3 votes
# Pip `-n`, 12 bytes

```
B X_.z@>_MEz

```

Try it online!

# Answer
> 2 votes
## CJam, 13 bytes

```
'[,65>_ffe>N*

```

Test it here!

### Explanation

```
'[,   e# Get character range from null-byte to 'Z'.
65>   e# Discard everything up to 'A', so we've got the upper case alphabet.
_     e# Duplicate.
ffe>  e# Nested map: for every pair of letters, computes the maximum and arranges the
      e# results in a grid.
N*    e# Join with linefeeds.

```

# Answer
> 2 votes
# Python 2, 61 bytes

```
a=range(65,91)
for c in a:print bytearray(max(c,i)for i in a)

```

Inspired by (xsot’s improvement to) this answer.

# Answer
> 2 votes
# C, ~~78~~ ~~70~~ 67 bytes

```
f(i,j){for(;++i<27;puts(""))for(j=0;++j<27;putchar((i>j?i:j)+64));}

```

The code makes use of the following golfing techniques for C:

* omit basic includes (like `stdio.h`)
* omit (return) types of functions and variables, making them default to `int`
* use the ternary operator instead of if-else blocks
* use the ASCII code of a letter instead of its char representation (i.e. `65` instead of `'A'`)
* use `putchar` to output a single character
* abuse main's argument list
* use `puts("")` to output a newline

Also, the rule `If it is a function, it must be runnable by only needing to add the function call to the bottom of the program.` does not forbid the function to be called with parameters (thanks to ABcDexter!).

Try it on Ideone

An ungolfed version (without any warnings with gcc) would look like this:

```
#include <stdio.h>

#define MAX(x, y) (x>y ? x : y)

int main()
{
    for(int i=0; i<26; i++)
    {
        for(int j=0; j<26; j++)
            printf("%c", MAX(i, j) + 'A');
        printf("\n");
    }
    return 0;
}

```

# Answer
> 2 votes
# Bash + coreutils, 55 51 bytes

Thanks to H Walters for 4 bytes.

```
for i in {A..Z};{ printf %c {A..Z} '
'|tr A-$i $i;}

```

We output the string `ABCDEFGHIJKLMNOPQRSTUVWXYZ` (+newline) 26 times, and replace the first `$i` characters with the `$i`th on each iteration. We take advantage of `tr` repeating the last character of the replacement set to extend it as necessary.

# Answer
> 2 votes
# C, ~~65~~ 63 bytes

```
i,k;a(j){for(;i++^702;j+=putchar(k?(j>k?j:k)+64:10)<11)k=i%27;}

```

Wandbox

# Answer
> 2 votes
# VBA, 60 Bytes

an Anonymous VBE immediate window function that outputs the L-phabet the the VBE immediate window.

```
For I=65To 90:For J=65To 90:?Chr(IIf(J>I,J,I));:Next:?:Next

```

# Answer
> 2 votes
# PHP, ~~65 62~~ 52 bytes

```
for($s=Z;$s++<ZZ;)echo"
"[$s[1]>A],max($s[0],$s[1]);

```

Why use `chr` when I can increment letters? Try it online.

---

old solution, 62 bytes:

```
for(;26>$b+=1/27;)echo chr(($a=++$a%27)?$a>$b?$a+64:$b+65:10);

```

similar approach as in my Tabula Recta answer

# Answer
> 2 votes
# x86 assembly (32-bit), 50 bytes

```
fd 57 c8 00 01 00 89 ef 4f 31 c0 aa b0 5a aa 48
e0 fc b0 41 fd 31 c9 b1 1b 89 ef 4f f2 ae f3 aa
50 47 57 e8 .. .. .. .. 58 58 40 3c 5a 7e e5 c9
5f c3

```

Might be optimizable further, but I'm tired.

Source:

```
/* output the l-phabet (???) - 32 bit */
.globl main
main:
std
push %edi
enter $256, $0
/* we're actually going to have to be careful with the stack on this one, since that's where the data is going */
/* first write our initial string */
mov %ebp, %edi
dec %edi
xor %eax, %eax
stosb
mov $'Z', %al
str:
stosb
dec %eax
loopnz str

/* now start back at the end */
mov $'A', %al
replace:
std
xor %ecx, %ecx
mov $27, %cl
mov %ebp, %edi
dec %edi
repne scasb
rep stosb
/* print */
push %eax
inc %edi
push %edi
call puts
pop %eax    /* caller cleanup */
pop %eax    /* old eax */
inc %eax
cmp $'Z', %al
jle replace
leave
pop %edi
ret

```

# Answer
> 2 votes
# Excel VBA, ~~40~~ 39 Bytes

Anonymous VBE immediate window function that takes no input and outputs to the ActiveSheet object

```
[A1:Z26]="=Char(Max(Column(),Row())+64)

```

# Answer
> 2 votes
# Pascal (FPC), 106 bytes

```
uses math;var c,d:word;begin for c:=65to 90do begin for d:=65to 90do write(chr(Max(c,d)));writeln;end;end.

```

Try it online!

# Answer
> 2 votes
# Pepe, ~~88~~ 85 bytes

```
REeEeeeeeErEeEeEEeEerEERREEEEEREEEereeREEEErerEEREEEEEEErereeerEEEEEeeEReeereeERrEree
```

Try it online!

# Answer
> 2 votes
# MUMPS, ~~63~~ ~~56~~ 53 bytes

```
f i=65:1:90 w ! f j=65:1:90 w:j>i $c(j) w:j<=i $c(i)

```

Can be expanded to:

```
for i=65:1:90 write ! for j=65:1:90 write:j>i $char(j) write:j<=i $char(i)

```

`!` is a new line. `write:<condition>` only writes if the condition returns true. `$char()` returns the character for an ASCII value.

# Answer
> 2 votes
# Java, 80 chars

```
for(int i=0,z=26;i<z*z;out.printf("%c%s",65+(i/z>i%z?i/z:i%z),++i%z>0?"":"\n"));

```

Try it online!

Explanation:

```
for(int // init
    i=0, // iterator variable
    z=26 // alphabet length constant
    ; // iterate through
    i<z*z // 26 lines of 26 characters
    ; // action after each iteration (print letters one-by-one)
    out.printf( // formatted output in one line
            "%c%s" // first argument - character, second argument - string
            , // first argument - character
            65+ // letter 'A' plus result of expression
               (i/z // line number
                   > // is greater then
                    i%z // letter position
                       ? // then
                        i/z // take line number
                           : // otherwise
                            i%z) // take letter position
            , // second argument - string
            ++ // iterator increment - go to next letter (before next iteration)
              i%z // letter position
                 >0 // is greater then 0
                   ? // then
                    "" // empty string (do nothing)
                      : // otherwise (first letter in the next line)
                       "\n" // add a line break before
    ));

```

Output:

```
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

# Answer
> 2 votes
# Deadfish~, 1293 bytes

```
{iiiiii}iiiiicicicicicicicicicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiii}iiiiiiccicicicicicicicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}dddcccicicicicicicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}ddccccicicicicicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}dcccccicicicicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}ccccccicicicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}icccccccicicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}iiccccccccicicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}iiicccccccccicicicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}iiii{c}icicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}iiiii{c}cicicicicicicicicicicicicicicic{{d}ii}c{iiiiii}iiiiii{c}ccicicicicicicicicicicicicicic{{d}ii}c{{i}ddd}ddd{c}cccicicicicicicicicicicicicic{{d}ii}c{{i}ddd}dd{c}ccccicicicicicicicicicicicic{{d}ii}c{{i}ddd}d{c}cccccicicicicicicicicicicic{{d}ii}c{{i}ddd}{c}ccccccicicicicicicicicicic{{d}ii}c{{i}ddd}i{c}cccccccicicicicicicicicic{{d}ii}c{{i}ddd}ii{c}ccccccccicicicicicicicic{{d}ii}c{{i}ddd}iii{c}cccccccccicicicicicicic{{d}ii}c{{i}ddd}iiii{cc}icicicicicic{{d}ii}c{{i}ddd}iiiii{cc}cicicicicic{{d}ii}c{{i}ddd}iiiiii{cc}ccicicicic{{d}ii}c{{i}dd}ddd{cc}cccicicic{{d}ii}c{{i}dd}dd{cc}ccccicic{{d}ii}c{{i}dd}d{cc}cccccic{{d}ii}c{{i}dd}{cc}cccccc

```

Try it online!

Magic.

# Answer
> 2 votes
# Pip `-l`, 10 bytes

```
z@MX GMC26

```

Attempt This Online!

### Explanation

```
z@MX GMC26
      MC    ; Map the following function over a square coordinate grid of size
        26  ; 26:
  MX        ;   Maximum of
     G      ;   The coordinate pair
 @          ;   Use that as an index into
z           ;   The lowercase alphabet

```

# Answer
> 2 votes
# Uiua, 12 characters (20 bytes)

```
≡&p⊞↥.+@A⇡26
          ⇡26  # The range [0 1 2 3 ... 25]
       +@A     # The alphabet
   ⊞↥.        # Create an array where the (i,j)th index is the maximum of the ith and jth character in the alphabet
≡&p           # Print each row

```

# Answer
> 1 votes
## Javascript (using external library) (141 bytes)

```
w=>_.Range(65,26).WriteLine(x=>(_.Range(0,x-65).Write("",y=>String.fromCharCode(x))||"")+_.Range(x,91-x).Write("",z=>String.fromCharCode(z)))

```

Link to lib:https://github.com/mvegh1/Enumerable

Code explanation: Create char code range of integers, for each write complex predicate to new line. Predicate will create a range of (currentValue-65) values, which is the part that goes A,BB,CCC,...etc...for the case of A the Write may return null so we coerce that to an empty string. Concatenate that with the remaining sequence of the alphabet. So many bytes are coming from the String.fromCharCode lol... oh well!!!

# Answer
> 1 votes
# VBA, 88 bytes

```
Function L:For i=0To 701:m=i Mod 27:d=m-i\27:L=L &IIf(26=m,vbLf,Chr(65+m+d*(d<0))):Next

```

An extension of my Tabula Recta answer. Again the last byte counted is the `enter` which generates the `End Function` statement. Invoke in the VBA editor Immediate window with `?L`.

# Answer
> 1 votes
## ListSharp, 233 bytes

```
ROWS s=ROWSPLIT "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" BY [","]
[FOREACH NUMB IN 1 TO 26 AS k]
{
STRG t=GETLINE s [k]
[FOREACH NUMB IN 1 TO k AS o]
STRG p=p+t
ROWS x=GETLINES s [k+1 TO 27]
STRG p=p+x+<newline>
}
SHOW=p

```

There are actually some tricks to get this shorter like directly accessing indexes or using c# queries since you can embed c# code in listsharp with some tricks.

But i kept it as in *vanilla* as possible

# Answer
> 1 votes
## Haskell, ~~43~~ 41 bytes

```
l=['A'..'Z']
m=mapM(putStrLn.(<$>l).max)l

```

This defines a function that needs no imports and can just be run in a complete program by adding

```
main=m

```

Of course, we could also just name it `main` itself, but that is three more bytes.

Saved 2 bytes thanks to @wchargin. Depending on the interpretation of the task, we can save 2 more by deleting `m=` and saying that the remaining part is the function that you can put into `main=...`

# Answer
> 1 votes
# Perl 6,  ~~67~~  64 bytes

```
~~my @a;@a[.[0]][.[1]]=('A'..'Z')[.max]for ^26 X ^26;.join.put for @a~~
my @a;@a[.[0];.[1]]=('A'..*)[.max]for ^26 X ^26;.join.put for @a
```

### Explanation:

```
my @a;

# @a[ $_.[0] ][ $_.[1] ]
@a[ $_.[0] ; $_.[1] ] = (

    # infinite Range that produces:
    #   'A',  'B',  'C' ...  'Y',  'Z',
    #  'AA', 'AB', 'AC' ... 'AY', 'AZ',
    #  'BA', 'BB', 'BC' ... 'BY', 'ZZ',
    # 'AAA','AAB','AAC' ... *｣
    'A' .. *

)[
    # index the Range with the max value in the "Tuple" ( 2 element List )
    $_.max
]

    for # do the above with each of the following "Tuples"

        # ｢(0,0),(0,1),(0,2)...(0,25),(1,0)...(25,25)｣
        ^26 X ^26;

$_.join.put for @a

```
* `.method` where a term is expected is an implicit method call on `$_` the "default" scalar.
* `^26` is short for `0 ..^ 26` which in this case is effectively the same as `0 .. 25`
* The meta infix operator `X` creates the cross product of two lists
( accepts an optional infix operator which it applies between the elements )

# Answer
> 1 votes
## K, 32 35 Bytes

3 more bytes to print the result without double quotes!

```
{-1,/[y#x@y-1;y _x]}[b]'1+!#b:.Q.A;
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

Explanation;

```
.Q.A                 --> uppercase alphabet
1+!#b:.Q.A           --> Indexes from 0 til (!) count (#) .Q.A (alphabet), and add 1 to them all. Also assign .Q.A to the variable b, so we don't have to type .Q.A again!
{}[b]'1 2 3 4 5....  --> we apply the function to b (alphabet) to each (') number i.e. 1 then 2 then 3 then 4
{,/[y#x@y-1;y _x]}   --> First time, y is 1;
    y#x@y-1              --> Use y-1 (0) to index (@) into x (alphabet), then take (#) y (1) of them i.e 1#"A" returns "A", 2#"A" returns "AA" etc.
    y _x                 --> drop (_) y many elements from x
,/[y#x@y-1;y _x]     --> flatten the result
-1 res;              --> Print the result

```

# Answer
> 1 votes
# Brainfuck, 126 bytes

```
++++++++++[<+++++++++<+>>-]>+++++[<+++++>-]<+[->>+++++[-<+++++<<----->>>]<+>>[-<+<<<+>>>>]<[->+<<-<<.>>>]>+<<[-<<.+>>]<<<.>->]

```

Still couldn't outgolf Dennis. Try it online!

## Explanation

(The random plusses are to offset hyphens/minuses used in the explanation)

```
+++++ +++++[<+++++ ++++<+>>-]
 Set the first cell to 10 (for the newline)
 Set the seccond cell to 90 (char code of Z to match the end result of the main loop

>+++++[<+++++>-]<+
 Set the third cell to 26 (the number of lines to make)
 Tape:
  10 90 26
        ^^

[- Main loop: runs 26 times (represented by n)

  >>+++++[-<+++++<<----->>>]<+
   Bring the second cell back to 65 (char code of A)
   Set the fourth cell to 26 (the number of letters per line)
   Tape on first time through loop:
    10 65 26-n 26  0  n
+              ^^

  >>[-<+<<<+>>>>]<
   The sixth cell contains a counter n of the number of lines we've done (initially zero)
   Add n to 65 (cell 2) to skip over the letters covered by the repeated letter
   Move the counter to cell 5
    10 65+n 26-n 26  n  0
                     ^
  [->+<<-<<.>>>]>+<<
    Move the counter back to cell 6
    Output the repeated character n times
    Subtract the n from cell 4 to leave room for only the non-repeated characters
    Increment n for next time
     10 65+n 26-n 26-n  0  n
++                ^^^^

  [-<<.+>>]
   Fill the remaining spots in the line with the rest of the alphabet by outputting cell 2 and incrementing
    10 91 26-n  0  0  n
+               ^

  <<<.>-
   Put a newline (cell 1)
   Change 91 to 90 because it's easier to subtract 25 than 26 to reset it
    10 90 26-n  0  0  n
+      ^^
>]

```

# Answer
> 1 votes
# \>\<\>, 77 bytes

```
v:1->:    ?!v!
>d2*^   v&:~<&o<
v!?&-1:&<o+'@':a!
>&~&>&:1+&d2*=?^&:&'@'+o43.

```

Try it online!

# Answer
> 1 votes
# Matricks, 37 bytes

```
m:26:26;Fs::[m90-Q:26-Q:26-Q;];:1:26;

```

Simple enough. Sets it to a blank 26x26 matrix, then consecutively overwrites the top left square with the correct ascii value.

Run with `python matricks.py lphabet.txt [[]] 0 --asciiprint`

# Answer
> 1 votes
## Actually, 13 bytes

```
5Pτú;∙♂M╪k♂Σi

```

Try it online!

-4 bytes from Leaky Nun, and the inspiration for 4 more, then 4 more from him, and 1 more from me

Explanation:

```
5Pτú;∙♂M╪k♂Σi
5Pτ            push 26
   ú;∙         Cartesian product of lowercase alphabet with itself
      ♂M       maximum of each pair
        ╪k     list of length-26 sublists
          ♂Σ   concatenate each sublist
            i  flatten and implicitly print

```

# Answer
> 1 votes
# Sesos, 24 bytes

```
0000000: 28eb92 02fcfe 8cabb2 36def7 f59933 37e09d 3976c7  (........6....37..9v.
0000015: 867307                                            .s.

```

Try it online! Check *Debug* to see the generated SBIN code.

### Sesos assembly

The binary file above has been generated by assembling the following SASM code.

```
add 10
rwd 1
add 26
jmp
    jmp
        rwd 3, add 1, fwd 3, sub 1
    jnz
    rwd 1, add 64, rwd 2
    jmp
        fwd 1, add 1, fwd 1, add 1, fwd 1, add 1, rwd 3, sub 1
    jnz
    fwd 1, sub 1
jnz
fwd 2
jmp
    jmp
        rwd 1, put, fwd 1, sub 1
    jnz
    fwd 1
    jmp
        put, fwd 2
    jnz
    rwd 2
    jmp
        rwd 1
    jnz
    fwd 2
jnz

```

### How it works

We start by placing **10** (linefeed) and **26** on the tape, leaving it as follows.

```
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
                                                                            v
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 26 10  0

```

We're going to count down from **26** to **1**, creating two copies of the counter: an unaltered one and one incremented by **64**. We do this because we have to print the letter with character code **64 + n** exactly **n** times before printing the remainder of the alphabet.

To count down as outlined above, we repeat the following process until the cell under the data head has a value of **0**.

First, we move the content of the counter cell three units to the right.

```
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
                                                                            v
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 26  0  0  0 10  0

```

Now, we retrocede three cells, increment the first one by **64**.

```
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
                                                                   v
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 26  0 64  0 10  0

```

Then, we (destructively) copy the content of the cell under the data head to the three closest cells to the right.

```
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
                                                                   v
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 26 90 26 10  0

```

Finally, we take a step to the right, decrement the counter, and repeat the process unless **0** is reached.

```
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
                                                                      v
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 25 90 26 10  0

```

We repeat this process **25** more times, then take two steps forward, leaving the tape as follows.

```
 0  0 65  1 66  2 67  3 68  4 69  5 70  6 71  7 72  8 73  9 74 10 75 11 76 12 77 13
          ^
78 14 79 15 80 16 81 17 82 18 83 19 84 20 85 21 86 22 87 23 88 24 89 25 90 26 10  0

```

Now we're ready to generate the output. We do so by repeating the following process until the cell under the data head has a value of **0**.

First we decrement the counter until it reaches **0**, printing the content of the cell to the left each time we decrement. After printing `A` and taking one step to the right, the tape looks as follows.

```
 0  0 65  0 66  2 67  3 68  4 69  5 70  6 71  7 72  8 73  9 74 10 75 11 76 12 77 13
             ^
78 14 79 15 80 16 81 17 82 18 83 19 84 20 85 21 86 22 87 23 88 24 89 25 90 26 10  0

```

We now print the content of the cell under the data head, take two steps to the right, and repeat until a **0** cell is reached. After printing `BCDEFGHIJKLMNOPQRSTUVWXYZ\n` and taking two steps to the left, the tape looks as follows.

```
 0  0 65  0 66  2 67  3 68  4 69  5 70  6 71  7 72  8 73  9 74 10 75 11 76 12 77 13
                                                                               v
78 14 79 15 80 16 81 17 82 18 83 19 84 20 85 21 86 22 87 23 88 24 89 25 90 26 10  0

```

We now go left until we find the next **0** cell, then take two steps to the right.

```
 0  0 65  0 66  2 67  3 68  4 69  5 70  6 71  7 72  8 73  9 74 10 75 11 76 12 77 13
                ^
78 14 79 15 80 16 81 17 82 18 83 19 84 20 85 21 86 22 87 23 88 24 89 25 90 26 10  0

```

In the next iteration, we'll print `BB`, then `CDEFGHIJKLMNOPQRSTUVWXYZ\n` and leave the tape as follows.

```
 0  0 65  0 66  0 67  3 68  4 69  5 70  6 71  7 72  8 73  9 74 10 75 11 76 12 77 13
                      ^
78 14 79 15 80 16 81 17 82 18 83 19 84 20 85 21 86 22 87 23 88 24 89 25 90 26 10  0

```

This process continues until all **26** lines are printed. After the last iteration, the data head is positioned on a **0** (see below), and the programs terminates.

```
 0  0 65  0 66  0 67  0 68  0 69  0 70  0 71  0 72  0 73  0 74  0 75  0 76  0 77  0
                                                                                v
78  0 79  0 80  0 81  0 82  0 83  0 84  0 85  0 86  0 87  0 88  0 89  0 90  0 10  0

```

# Answer
> 1 votes
## Lua, ~~108~~ ~~85~~ 86 Bytes

**EDIT: saved 23 Bytes thanks to @LeakyNun**

~~A Lua program without any spaces! It's so rare that I think it's worth telling it!~~

It simply outputs line by line to STDOUT.

```
s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"for i=1,26 do s=s:sub(i,i):rep(i)..s:sub(i+1)print(s)end

```

### Ungolfed

```
s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"  -- shortest way to generate the alphabet is to hardcode it
for i=1,26                      -- loop once for each character
do
  s=s:sub(i,i)                  -- replace the current string by using its i-th character
     :rep(i)                    -- repeating it i-th times
    ..s:sub(i+1)                -- and concatenating with the rest of the string
print(s)                        -- we then can print it out
end

```

# Answer
> 1 votes
# Pyth, 9 bytes

```
V._GXGNeN

```

Try it online: Demonstration

### Explanation:

```
V._GXGNeN   implicit: G = "abc...xyz"
 ._G        all prefixes of G: ["a", "ab", "abc", ...]
V           for each prefix N:
    XGNeN      replace the letters of N in G by the last letter of N

```

Another pretty interesting solution (12 bytes):

```
j.uXN.*<{N2G

```

First time that `.*` is useful!

# Answer
> 1 votes
# Sprects, 316 bytes

```
:ABCDlBBCDlCCCDlDDDDlEEEElFFFFFFGcGGGGGGGcHHHHHHHcIIIIIIIIIJq00q11qttttMauuuuMavvvvNarrrrrPQknnnnQkooooQkppppRkmmmmmmSTbiiiiibjjjjjbgggggggVs
hhhhhhhWs
ffffffYZ
dddddZ
eeeeeZ:1KKKKK:0JJJJJ:dYYYYY:eZZZZZ:fXXXX:gVVV:hWWW:iTTTT:jUUUU:lEFGc:cHIJq:mSSS:nPPPP:oQQQQ:pRRRR:qKLMa:aNOPQk:kRSTb:bUVs
:rOOO:sWXYZ:tLLL:uMMM:vNNN

```

Basically Martin Ender's /// answer ported to Sprects and then golfed. `\n`s appear as spaces, this is the interpreter's error.

# Answer
> 1 votes
## Lua, ~~81~~ 80 bytes

*Saved 1 byte thanks to manatwork*

```
w=io.write for i=65,90 do for j=65,90 do w(('').char(math.max(i,j)))end w'\n'end

```

# Answer
> 1 votes
# QB64, 75 bytes

Not a winner, but not bad for BASIC. Too bad it doesn't have a built-in `MAX` function.

```
FOR y=65 TO 90
FOR x=65 TO 90
IF x>y THEN?CHR$(x);ELSE?CHR$(y);
NEXT
?
NEXT

```

# Answer
> 1 votes
# Pyth - 12 bytes

```
WG.[hG26G=tG

```

Explanation:

```
                    #G is autoinitialized to the lowercase alphabet
WG                  #while G is not empty
  .[                #left pad
        G           #G
    hG              #with the first letter of G
      26            #to a length of 26
                    #implicitly print that
         =tG        #remove the first letter of G

```

# Answer
> 1 votes
# Ruby, 60 bytes

```
a=("A".."Z").to_a.join;(0..25).map{|i|puts(a[i]*i+a[i..-1])}

```

# Answer
> 1 votes
# F#, 70 bytes

```
for i in 'A'..'Z'do(for j in 'A'..'Z'do printf"%c"(max i j));printfn""

```

Pretty straightforward.

# Answer
> 1 votes
# Java 1.8, ~~96~~ 91 bytes

I managed to flatten everything into one for-loop with a single print statement. Nothing Java 1.8 specific - just happens to be the version I compiled the code with.

~~```
void f(){for(int i=-1,j=0,k=i;++i<702;k=(i+1)%27)System.out.write(k>25?++j-j+10:65+(k>j?k:j));}

```~~

Surprisingly, removing variable `k` and introducing `Math.max()` skimmed off 5 bytes:

```
void f(){for(int i=-1,j=0;++i<702;)System.out.write(i%27>25?++j-j+10:65+Math.max(i%27,j));}

```

Or ungolf'ed:

```
interface C {
    static void main(String[] a) {
        f();
    }

    static void f() {
        for (int i = -1, j = 0; ++i < 702;) {
            System.out.write(i%27 > 25 ? ++j - j + 10 : 65 + Math.max(i%27,j));
        }
    }
}

```

Try it here.

Approach is based on my Tabula Recta answer. This leverages the fact that the `System.out` stream is line-buffered, causing an auto-flush whenever a line feed character (`10`) is written.

I have a feeling this can be golf'ed down further, mainly because of the way the values of certain variable are juggled with (i.e. `j`). *Note to self: I was right!*.

# Answer
> 1 votes
# Ruby, ~~49~~ 47 Bytes

Shaved off two bytes thanks to a simple () removal as per @manatwork, though his answer is even better at 45 bytes (see comment)

```
a=?A..?Z;a.map{|x|a.map{|y|$><<[x,y].max};puts}

```

Ungolfed:

```
('A'..'Z').map{|x|
  ('A'..'Z').map{|y|
    print [x,y].max
  }
  puts
}

```

Or using a stabby lambda to print out character by it's index, 76 bytes:

```
l=->i,j{$><<(i+65).chr*j};26.times{|i|l[i,i];(26-i).times{|j|l[i+j,1]};puts}

```

Ungolfed:

```
def printChar(char,num)
  print (char+65).chr*num
end

26.times { |i|
  printChar(i,i)
  (26-i).times{|j| printChar(i+j,1)}
  puts
}

```

A less complicated version (that doesn't use the string * op) at 77 bytes:

```
l=->i{$><<(i+65).chr};26.times{|i|i.times{l[i]};(26-i).times{|j|l[i+j]};puts}

```

# Answer
> 1 votes
# Python 2.7, 79 bytes

```
x=[chr(y) for y in range(65,91)]
for y in range(26):print x[y]*y+''.join(x[y:])

```
1. Generate a list of the characters.
2. Loop through each showing the beginning character a certain amount of times.
3. Then show the rest after that.

# Answer
> 1 votes
# JavaScript, 101 bytes

Not as short as the other and probably doesn't have much room for improvement without changing how it works, but this was the solution I came up with without looking at any of the other answers first.

```
s=String.fromCharCode
for(l=0;l<26;){o=s(65+l).repeat(l)
for(i=l++;i<26;)o+=s(65+i++)
console.log(o)}
```

# Answer
> 1 votes
## Neoscript, 62 bytes (non-competing)

```
a='A:[]:'Zeach n=0:[]:25console:log(a[n]*n+a:slice(n):fuse());

```

# Answer
> 1 votes
# Brachylog, ~~20~~ 19 bytes

```
~~@Ae:@Az:{ot.}acw@Nw\~~
@Ae:@Az:oa:tacw@Nw\

```

Try it online!

# Answer
> 1 votes
# TSQL, 107 bytes(boring version)

Golfed:

```
DECLARE @ INT=0z:PRINT STUFF('ABCDEFGHIJKLMNOPQRSTUVWXYZ',1,@,REPLICATE(CHAR(@+65),@))SET
@+=1IF @<26GOTO z

```

Ungolfed:

```
DECLARE @ INT=0
z:
PRINT STUFF('ABCDEFGHIJKLMNOPQRSTUVWXYZ',1,@,REPLICATE(CHAR(@+65),@))
SET @+=1
IF @<26GOTO z

```

Fancy solution as SELECT without looping:

**Fiddle(boring solution)**

# TSQL, 168 bytes(the interesting solution)

USE MASTER will be necessary if you have set a default database for your sql user

Golfed:

```
USE MASTER;
WITH n(n)as(SELECT number FROM spt_values WHERE'P'=type and number<26)SELECT(SELECT char(65+IIF(x.n>n,x.n,n))FROM n FOR xml path(''),type).value('.','char(51)')FROM n x

```

Ungolfed:

```
USE MASTER;
WITH n(n)as
(
  SELECT number
  FROM spt_values
  WHERE'P'=type and number<26
)
SELECT
(
  SELECT char(65+IIF(x.n>n,x.n,n))
  FROM n
  FOR xml path(''),type).value('.','char(51)')
FROM n x

```

**Fiddle for interesting solution**

# Answer
> 1 votes
# QBIC, 42 bytes

```
[26|D=Z[26|c=b~a>b|c=a]D=D+chr$$(c+64)|]?D

```

I should really make a `CHR$` function in QBIC...

Output:

```
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

# Answer
> 1 votes
# Commodore 64 195 bytes 182 bytes 135 bytes 126 bytes 123 122 tokenised BASIC bytes

Here is a version for the Commodore 64 (will also work with other Commodore BASIC most likely) - although the machine only displays 25 rows in BASIC by default, you can at least see the first row as BASIC is slow.

```
 0 x=0:fory=i+65to90:on-(i>0)and-(x=0)gosub1:printchr$(y);:next:print:i=i+1:on-(i<26)goto:end
 1 x=1:forz=1toi:printchr$(y);:next:return

```

Written with CBM prg Studio. I'll see if I can work out a 6502 version at some point.

print 38911-(fre(0)-65536\*(fre(0)\<0)) shows 123 bytes used.

GuitarPicker's solution had me thinking of a better way; unfortunately there is no if/else in Commodore BASIC v2 but this is probably more efficient than my previous one. Althoug BASIC 7 does have this facility for the Commodore 128 (native).

I've taken out the infinite loop in the previous version and not initialised the i variable as you don't need to do that - saving 9 bytes.

Saved another byte because `goto` in CBM BASIC V2 assumes `goto 0` if no number is entered, so removed the `on...goto0` saving a whole token!

Further minimisation has meant that I could add end to like 0, hence removing `1 end` and moving up line to for the sub-routine, saving another few bytes.

# Answer
> 1 votes
# k, 29 bytes

```
o:{-1@(y#*x),x:y_x}[.Q.A]'!26

```

This prints to the console, without quotes. Setting the return to a variable ("o") suppresses the output of the function in the k interpreter, so nothing will be returned by the execution of the function.

Get kdb+ here

# Answer
> 1 votes
# Binary-Encoded Golfical, ~~105~~ ~~88~~ 83 bytes

This encoding can be converted back to Golfical's standard graphical format using the encoder/decoder provided in the Golfical github repo, or run directly by using the `-x` flag.

Hexdump of binary encoding:

```
00 D0 05 1C 00 5A 10 40 1B 14 1B 14 00 41 1A 14
1B 14 14 14 27 0C 05 14 14 14 14 0C 02 14 14 14
14 08 04 14 14 14 14 00 42 14 14 14 04 01 1B 04
01 08 02 1A 0A 02 27 0A 02 18 1D 50 0A 02 14 14
14 18 1B 04 01 1A 14 00 0A 27 18 1D 14 4F 1C 14
14 14 1D

```

Original image (the layout of the program can probably be compacted further):

Scaled up 36x:

# Answer
> 1 votes
# MySQL, 311 bytes

```
delimiter // create procedure t() begin declare p,r int;declare q varchar(726);set r:=0;set q:="";while r<26 do set p:=65+r;set q:=concat(q,rpad("",r,char(p)));while p<91 do set q:=concat(q,char(p));set p:=p+1;end while;set q:=concat(q,"\r\n");set r:=r+1;end while;select q from dual;end //
delimiter ;
call t()

```

# Answer
> 1 votes
# Befunge, 55 bytes

```
:39*%"A"+:"["/99**-,:"d"7*`#@_1+::39*/\39*%`55+*"%"+40p

```

Try it online!

# Answer
> 1 votes
# Pushy, 14 bytes

```
A65vL:^K&Mkhv"

```

**Try it online!**

```
A     \ Push the uppercase alphabet
65v   \ Push 65 (char 'A') to the second stack, as a counter.
L:    \ Length (26) times do:
 ^K&M \   Make every character max(char, counter)
 khv  \   Increment the counter
 "    \   Print the characters

```

# Answer
> 1 votes
# Common Lisp, SBCL, ~~100~~ ~~97~~ 96 bytes

```
(dotimes(i 26)(format t"~26,,,v@a
"(code-char(+ 65 i))(subseq"ABCDEFGHIJKLMNOPQRSTUVWXYZ"i 26)))

```

### Ungolfed

```
(dotimes(i 26);loop from i=0 to 26
(format t"~26,,,v@a
"(code-char(+ 65 i))(subseq"ABCDEFGHIJKLMNOPQRSTUVWXYZ"i 26)))
;output i times character with code 65+i followed by rest of alphabet

```

Ideas for improvement are welcomed

# Answer
> 1 votes
# Japt, 15 bytes

```
;B¬£B®<X?X:Z}Ã·

```

Test it online!

# Japt -R, 12 bytes

```
;B¬£B®<X?X:Z

```

Test it online!

# Answer
> 1 votes
# q/kdb+, ~~20~~ 14 bytes

**Solution:**

```
-1{x|/:x}.Q.A;

```

**Example:**

```
q)-1{x|/:x}.Q.A;
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

**Explanation:**

Takes the alphabet and then performs the max (`|`) of each character in turn over itself (`/:`). For the first pass, we compare `A` against each letter, as `A < B < C` we get the full alphabet `ABCDE...`, for the next we take B, B\>A hence `BBCDE...` etc.

```
-1{x|/:x}.Q.A; / ungolfed
-1           ; / print result to stdout
         .Q.A  / "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  {     }      / lambda function
   x|/:x       / x max (&) each-right (/:) x

```

# Answer
> 1 votes
# K (oK), ~~21~~ 19 bytes

**Solution:**

```
`0:`c$a|/:a:65+!26;

```

Try it online!

**Explanation:**

`K` port of my q/kdb+ answer.

```
`0:`c$a|/:a:65+!26; / solution
`0:               ; / write to stdout and swallow return value
               !26  / til 26, range 0..25
            65+     / add 65 (vectorised), ASCII A = 65
          a:        / save in variable a
      a|/:          / a max (&) each-right (/:) a
   `c$              / cast to string

```

# Answer
> 1 votes
# uBASIC, 75 bytes

Anonymous uBASIC function that takes no input and outputs the L-phabet

```
0ForI=65To90:ForJ=65To90:K=J:IfI>JThenK=I
1?Left$(Chr$(K),1);:NextJ:?:NextI

```

Try it online!

# Answer
> 1 votes
# Japt v1.4.5 `-R`, 9 bytes

```
;B¬£BcwXc

```

Try it online!

### Unpacked & How it works

```
;Bq mXYZ{BcwXc

;               Use an alternative set of predefined variables
 B              "ABC...Z"
  q mXYZ{       Split into chars and map...
         Bc       Map over uppercase alphabets' charcodes...
           wXc      Take max of this and charcode of X

-R              Join by newline before implicit output

```

# Answer
> 1 votes
# Lua, 83 bytes

Each iteration of the loop prints out the `i`th letter of the alphabet `i` times and then prints all of the letters after that.

```
a="ABCDEFGHIJKLMNOPQRSTUVWXYZ"for i=1,26 do print(a:sub(i,i):rep(i)..a:sub(i+1))end

```

# Answer
> 1 votes
# JavaScript (ES6), 89 bytes

```
for(i=0;i++<26;){s="";for(j=27;--j;)s=String.fromCharCode(64+(j<i?i:j))+s;console.log(s)}

```

# Answer
> 1 votes
# Japt `-R`, 9 bytes

```
;B¬£BhXpY

```

Try it

```
;B            :Uppercase alphabet
  ¬           :Split
   £          :Map each X at 0-based index Y
    B         :  Uppercase alphabet
     h        :  Replace as many characters as necessary at the start of that string with
      XpY     :    X repeated Y times
              :Implicit output, joined with newlines

```

# Answer
> 1 votes
# GolfScript, ~~57~~ ~~48~~ ~~27~~ 26 bytes

```
91,65>^1/:&,,{)&(\:&;*&n}/

```

Try it online!

```
91,                         # Make an array from 0 to 90
   65>                      # Remove every number up to 64
      ^                     # Parse to a string
       1/:&                 # Make an array with all letters and store it in the variable &
           ,,               # Make an array from 0 to 25
             {          }/  # Execute this block for each number in the array
              )             # Increment
               &(\:&;       # Remove the first letter of & and push it
                     *      # Multiply the letter by that increased number
                      &n    # Push the letters left in & and a newline

```

First 7 bytes are based on this solution for another problem.

# Answer
> 1 votes
# Pyth, 12 bytes

```
VUG+*@GNN>GN

```

Try it online!

```
VUG+*@GNN>GN
VUG            For N in 26:
   +             Join the following:
    *@GNN           The Nth element of the alphabet, repeated N times.
         >GN        The alphabet, starting from the Nth element.

```

# Answer
> 1 votes
# Vyxal, `j`, ~~13~~ ~~9~~ 8 bytes

```
kA:ẊvG∑²

```

Try it Online!

4 bytes off by porting jelly and -1 from Aaron.

## Explained (old)

```
kA:ẊvG26ẇ
kA        # "ABCDEF....XYZ"
  :       # ↑, ↑
   Ẋ      # cartesianProduct(↑)
    vG    # max of each item in ↑
      26ẇ # ↑ wrapped into lengths of 26

```

# Answer
> 1 votes
# Clojure, 122 bytes

```
(let [x(map char(range 65 91))](run! #(println(apply str %))(map #(concat(repeat %1 %2)(drop %1 %3))(range)x(repeat x))))

```

# Answer
> 1 votes
# Python, 69 bytes

```
a="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
[print(a[n]*n+a[n:])for n in range(26)]

```

Try it online!

# Answer
> 1 votes
# Excel (Office 365 Insider Preview), 47 bytes

An anonymous worksheet function that takes no input and outputs the L-phabet as a \\$26\times 26\\$ dynamic array to the calling cell.

This solution makes use of the `=MAKEARRAY()` and `=LAMBDA()` functions, which are currently only available via the Office Insiders program.

```
=MakeArray(26,26,Lambda(r,c,Char(Max(r,c)+64)))

```

### Annotated

```
=MakeArray(26,26,                             ) ' Make a 26x26 array holding row & col index
                 Lambda(r,c,                 )  ' Pass the indices into a function
                                 Max(r,c)       ' Take the larger of two at each position
                            Char(        +64)   ' Add 64, and cast as char
                                                ' Output as 26x26 dynamic array

```

# Answer
> 1 votes
# Python 3, 85 bytes

Based off @ugoren's Excel answer, here's my Python 3 answer that isn't special at all.

```
for c in range(26):
    for r in range(26):print(chr(65+max(c,r)),end='')
    print()

```

Explanation:

```
for c in range(26):     # The grid is 26x26,
    for r in range(26): # so we have to do 2 for loops
                       print(chr(65+max(c,r)),end='') # Some formula to print the letter at coordinates (c, r)
    print() # Print a newline after a row so that we can print the next row

```

# Answer
> 0 votes
# Java 8, ~~93~~ ~~95~~ 85 bytes

```
o->{String r="";for(char i=64,j;++i<91;r+="\n")for(j=64;++j<91;)r+=i>j?i:j;return r;}

```

**Explanation:**

Try it here.

```
o->{                   // Method with an empty unused parameter and a String return-type
  String r="";         //  Result-String
  for(char i=64,j;     //  Index characters
      ++i<91;          //  Loop (1) from 'A' through 'Z'
      r+="\n")         //    And append a new-line after every iteration
    for(j=64;++j<91;)  //   Inner loop (2) from 'A' through 'Z'
      r+=i>j?          //    If `i` comes later in the alphabet than `j`
          i            //     Append the result-String with `i`
         :             //    Else:
          j;           //     Append the result-String with `j`
                       //   End of inner loop (2) (implicit / single-line body)
                       //  End of loop (1) (implicit / single-line body)
  return r;            //  Return result-String
}                      // End of method

```

# Answer
> 0 votes
# C# (6.0), 173 148 Bytes

*Reduced by 25 Bytes thanks to asibahi*

First time code-golfing.

```
namespace System{class P{static void Main(){for(var i=65;i<91;++i){var a="";for(var j=65;j<91;++j)a+=(char)(Math.Max(i,j));Console.WriteLine(a);}}}}

```

In "readable":

```
namespace System
{
  class P
  {
    static void Main()
    {
      for (var i = 65; i < 91; ++i)
      {
        var a="";
        for (var j = 65; j < 91; ++j)
          a+=(char)(Math.Max(i,j));
        Console.WriteLine(a);
      }
    }
  }
}

```

I obviously cannot compete with other answers, but C# doesn't give much more opportunity ;-)

# Answer
> 0 votes
## Pyke, ~~14~~ ~~11~~ 10 bytes

```
GFoj*Gj>ns

```

Try it here!

# Answer
> 0 votes
# Scratch (scratchblocks), 323 bytes

```
when gf clicked
set [a v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZ
set [l v] to [1
repeat (26
  set [o v] to [
  repeat (l
    set [o v] to (join (o) (letter (l) of (a
  end
  set [i v] to (l
  repeat ((26) - (l
    change [i v] by (1
    set [o v] to (join (o) (letter (i) of (a
  end
  say (o) for (1) secs
  change [l v] by (1
end

```

Proof the scratchblocks works (assuming the add "to backpack" feature still exists!), and a project demoing it.

**EDIT: At a certain width, Scratch hard-wraps speech bubbles, which I use for output.** There isn't really anything I can do about that.

---

# Scratch, 74 bytes

```
when gf clicked
replace item (1 v) of [l v] with ([costume name v] of [_ v

```

A project demoing it.

This is definitely a hack!

(It could actually be shortened a bit but then it would break if you ran the project twice. This relies on a project that is.. well, exactly as the demo project!)

# Answer
> 0 votes
# C++, 147 bytes

.\_. No idea why this is too long but here u go

```
#include <iostream>
int i;main(){for(;i<26;i++){int j;for(j=0;j++<=i;){putchar('a'+i);}for(j=i+1;j++<26;){putchar('a'+j-1);}std::cout<<std::endl;}}

```

# Answer
> 0 votes
# C, 75 bytes

Assuming ASCII (or compatible) encoding:

```
F(i,j){for(i=65;i<91;++i){for(j=65;j<91;++j)putchar(j<i?i:j);putchar(10);}}

```

Test `main`:

```
int main() { F(); }

```

# Answer
> 0 votes
# C#, ~~139~~ ~~136~~ ~~134~~ 131 bytes

```
void a(){for(char i='A';i<'[';i++){char j;for(j='A';j<i;j++)Console.Write(i);for(;j<'[';j++)Console.Write(j);Console.WriteLine();}}

```

Ungolfed:

```
void a()
{
    for (char i = 'A'; i < '['; i++)
    {
        char j;

        for (j = 'A'; j < i; j++)
            Console.Write(i);

        for (; j < '['; j++)
            Console.Write(j);

        Console.WriteLine();
    }
}

```

EDIT1: Sharing `j` variable by inner loops maked profit of 3 bytes.

EDIT2: Changing `i <= 'Z'` to `i < '['` maked profit of 2 bytes.

EDIT3: Removal of `j` initialization in second inner loop maked profit of 3 bytes.

# Answer
> 0 votes
## Commodore 128 (BASIC 7) 52 bytes

This is based on GuitarPicker's soltion above. In fact, it's a carbon copy but with line numbers, also then should be added after if conditions in Commodore BASIC.

```
    0 fory=65to90:forx=65to90:ifx>ythenprintchr$(x);:elseprintchr$(y);
    1 next:print:next

```

This might also be compatible with the Commodore Plus/4 and C16/116 (which has BASIC 3.5)

# Answer
> 0 votes
**PHP, 120 bytes**

```
<?$a='ABCDEFGHIJKLMNOPQRSTUVWXYZ';$b=65;$c=26;while($c>0){echo str_repeat(chr($b++),26-$c).substr($a,26-$c--).'<br>';}?>

```

# Answer
> 0 votes
## Racket 117 bytes

```
(let((d display)(g integer->char))(for((i 26))(for((j i))(d(g(+ i 65))))(for((k(range i 26)))(d(g(+ k 65))))(d"\n")))

```

Ungolfed:

```
(define(f)
  (let ((d display)
        (g integer->char))
    (for ((i 26))
      (for ((j i))
        (d (g (+ i 65))))
      (for ((k (range i 26)))
        (d (g (+ k 65))))
      (d"\n"))))

```

Testing:

```
(f)

```

Output:

```
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ

```

# Answer
> 0 votes
# Pyth, 16 bytes

I'm guessing I'm doing it entirely wrong.

```
VlG=H>rG1N+*hHNH

```

Explanation:

```
VlG       For every letter in the alphabet.
 =H>rG1N  Get every entry past N in the uppercase alphabet (rG1) and store it in H.
 +*hHNH   Output the first letter times the iteration appended to the truncated uppercase alphabet.

```

Try it online!

# Answer
> 0 votes
# Bubblegum, 118 bytes

```
00000000: e002 bc00 6c5d 0020 9084 76ba 8a75 cfb4  ....l]. ..v..u..
00000010: 0db2 e89f 1387 f805 577d ecad ee74 7800  ........W}...tx.
00000020: eec1 2f25 c599 ffad a853 3436 8feb d31b  ../%.....S46....
00000030: 82d8 8903 257e e382 db1a 762d 7165 8aff  ....%~....v-qe..
00000040: b5a1 0ce7 aef8 6f11 df37 a113 cae8 1bf5  ......o..7......
00000050: cb63 3fc8 6759 ad3c 9623 3ff4 eec3 aa59  .c?.gY.<.#?....Y
00000060: 0467 2b17 046c 0fa7 33a2 03aa d932 36b7  .g+..l..3....26.
00000070: 26fe c600 0d0a                           &.....

```

Try it online!

# Answer
> 0 votes
# Thotpatrol, 907 bytes

```
JACKING IN
DM THAUGHTY ALLIE
DM THAUGHTY LAURA
DM THOTTY KATY
DM THOTTY MARINA
DM THAUGHTY KATE
ALLIE  ©ABCDEFGHIJKLMNOPQRSTUVWXZY©
KATY   ™0™
MARINA  ™0™
❤PRIME ASSETS❤ MARINA  ™25™
LAURA  ©©
KATY   ™0™
❤PRIME ASSETS❤ KATY  ™25™
BRIEF KATY  MARINA
KATE  ALLIE  MARINA
LAURA  LAURA REDACTED KATE
DEBRIEF
BRIEF KATY  MARINA
KATE  ALLIE  KATY
LAURA  LAURA REDACTED KATE
DEBRIEF
KATY  KATY  ™1™
INTERCEPT MALIGNANT COMMUNICATIONS
  LAURA REDACTED ©
©
MARINA  MARINA  ™1™
INTERCEPT MALIGNANT COMMUNICATIONS
NAUGHTY THAUGHTY ALLIE
NAUGHTY THOTTY KATY
NAUGHTY THAUGHTY KATE
NAUGHTY THOTTY MARINA
REPORT UNPATRIOTIC ACTIVITY

```

I challenge others to optimize this further. Thotpatrol is not an efficiency-friendly language.

Link to interpreter: https://github.com/MindyGalveston/thotpatrol-

# Answer
> 0 votes
# Thotpatrol, 576 bytes

```
JACKING IN
DM THAUGHTY AI
AI  ©ABCDEFGHIJKLMNOPQRSTUVWXYZ©
DM THOTTY AN
DM THOTTY FE
FE  ™0™
❤PRIME ASSETS❤ FE  ™25™
AN  ™0™
❤PRIME ASSETS❤ AN  ™25™
BRIEF AN  FE
  AI  FE
DEBRIEF
BRIEF AN  FE
  AI  AN
DEBRIEF
AN  AN  ™1™
INTERCEPT MALIGNANT COMMUNICATIONS
  ©
©
FE  FE  ™1™
INTERCEPT MALIGNANT COMMUNICATIONS
REPORT UNPATRIOTIC ACTIVITY

```

Pretty much the same sort of logic as @Mr.Negi except I have scrapped a number of unnecessary commands, used shorter variable names and printed directly rather than putting value into a variable first.

# Answer
> 0 votes
# Common Lisp, 84 bytes

```
(dotimes(i 26)(format t"~a
"(fill #1="ABCDEFGHIJKLMNOPQRSTUVWXYZ"(elt #1#i):end i)))

```

Try it online!

# Answer
> 0 votes
# VBA (EXCEL) , 111 Bytes

```
Sub c()

For x=0 To 25
For y=0 To 25
b=y
If y<x Then b=x
a=a&Chr(65+b)
Next
a=a&vbNewLine
Next
MsgBox a
End Sub

```

# Answer
> 0 votes
# Charcoal, 10 bytes

```
Ｆ⮌αＢ⁻℅ι⁶⁴ι

```

Try it online!

Explanation:

```
Ｆ           For each
 ⮌α          letter in the reversed uppercase alphabet
   Ｂ         draw a box
     ⁻℅ι⁶⁴    of size the ascii code of the letter minus 64
     ι        and use the iterated char as border

```

# Answer
> 0 votes
# SOGL V0.12, 18 bytes

```
Zl∫ZFH⌡k±JM*+Z⁄m±P

```

Try it Here!

SOGL doesn't have string comparison :/

# Answer
> 0 votes
# , 24 bytes

```
(,~{.#~26-#)\.65}.91{.a.

```

Try it online!

```
              65}.91{.a.   the alphabet
            \.             for each suffix starting from the longest
(      26-#)               subtract length from 26
(  {.      )               first character
(    #~    )               repeated n times
(,~        )               prepend

```

# Answer
> 0 votes
# Jelly, 13 bytes

```
ØAxJŒgżṫJ‘$$Y

```

Try it online!

# Answer
> 0 votes
# MY-BASIC, 79 bytes

Anonymous function that takes no input and outputs to the console

```
For I=65 To 90
For J=65 To 90
K=J
If I>K Then K=I
Print Chr(K)
Next
Print;
Next

```

Try it online!

# Answer
> 0 votes
# Visual Basic .NET (.NET Core), 127 bytes

Declared function that takes no input and outputs the L-phabet to the console.

```
Module M
Sub Main
Dim S
For I=65To 90
S=""
For J=65To 90
S+=ChrW(If(I>J,I,J))
Next
Console.WriteLine(s)
Next
End Sub
End Module

```

Try it online!

# Answer
> 0 votes
# Yabasic, 53 bytes

Takes no input and outputs to STDOUT

```
For I=65To 90
For J=65To 90?Chr$(Max(J,I));Next
?Next

```

Try it online!

# Answer
> 0 votes
# QBasic, 69 bytes

An undeclared subroutine that takes no input and outputs to STDOUT

```
For I=65To 90
For J=65To 90
K=J
If I>K Then K=I
?Chr$(K);
Next
?
Next

```

# Answer
> 0 votes
# Small Basic, 107 bytes

Script that takes no inpu and outputs to the `TextWindow`

```
For I=65To 90
s=""
For J=65To 90
s=s+Text.GetCharacter(Math.Max(J,I))
EndFor
TextWindow.WriteLine(s)
EndFor

```

### Output

# Answer
> 0 votes
# Gol\>\<\>, ~~41~~ 28 bytes

```
asFaLF"Z"L-|Lm*jasL-F"Z"+||H

```

Try it online!

# Answer
> 0 votes
# Stax, 5 bytes

```
VAcKT

```

Run and debug it

## Explanation

```
VAcKT
VA    uppercase alphabet
  c   copy
   K  cross-product map short-form(displays with newlines):
    T  max of two values

```

# Answer
> 0 votes
# Knight, 48 bytes

```
;=i 64W>91=i+1i;=j 64;W>91=j+1jO+I>i jAiAj"\"O""

```

Try it online!

# Answer
> 0 votes
# Vyxal 3 \`\`, 17 bytes

```
₂ʀ(nkAinꜝ×nꜝkAİ+,

```

Try it Online! (link is to literate version)

# Answer
> 0 votes
# C, 87 bytes

```
#include<stdio.h>
#define S(n) for(n=0;n<26;n++)
main(){int i,j;S(i){S(j)putchar(65+(j<i?i:j));puts("");}}

```

Try it online!

# Answer
> 0 votes
# Vyxal 3 `j`, 8 bytes

```
mmẊᵛƓ₂Ẇ“

```

Try it Online!

---
Tags: code-golf, kolmogorov-complexity, alphabet
---


title: N-Queens Puzzle

text:
# Question
Title: N-Queens Puzzle
*(Despite 60+ questions tagged , we don't have a simple n-queens challenge.)*

In chess, the N-Queens Puzzle is described as follows: Given an `n x n` chessboard and `n` queens, arrange the queens onto the chessboard so that no two queens are threatening each other. Below is an example solution for `n = 8`, borrowed from Wikipedia.

Or, in ASCII rendering:

```
xxxQxxxx
xxxxxxQx
xxQxxxxx
xxxxxxxQ
xQxxxxxx
xxxxQxxx
Qxxxxxxx
xxxxxQxx

```

The challenge here will be to take input `n` and output an ASCII representation of a solution to the `n`-Queens puzzle. Since there are more than one possible solution (e.g., at the least, a rotation or reflection), your code only needs to output any valid solution.

## Input

A single positive integer `n` with `n >= 4` in any convenient format. (n=2 and n=3 have no solutions, and n=1 is trivial, so those are excluded)

## Output

The resulting ASCII representation of a solution to the N-queens puzzle, as outlined above. You may choose any two distinct ASCII values to represent blank spaces and queens. Again, this can be output in any suitable format (single string, a list of strings, a character array, etc.).

## Rules

* Leading or trailing newlines or whitespace are all optional, as well as whitespace between characters, so long as the characters themselves line up correctly.
* You can either use an algorithm to calculate the possible positions, or use the explicit "stair-step" style of solution, whichever is golfier for your code.
* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* If possible, please include a link to an online testing environment so other people can try out your code!
* Standard loopholes are forbidden.
* This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

## Examples

```
n=4
xQxx
xxxQ
Qxxx
xxQx

n=7
xxQxxxx
xxxxxxQ
xQxxxxx
xxxQxxx
xxxxxQx
Qxxxxxx
xxxxQxx

n=10
xxxxQxxxxx
xxxxxxxxxQ
xxxQxxxxxx
xxxxxxxxQx
xxQxxxxxxx
xxxxxxxQxx
xQxxxxxxxx
xxxxxxQxxx
Qxxxxxxxxx
xxxxxQxxxx

```

# Answer
# C, 114 bytes

```
Q(n,o,y){o=n%2;n-=o;for(y=0;y<n+o;++y)printf("%*c\n",y<n?o+n-(n+y%(n/2)*2+(n%6?y<n/2?n/2-1:2-n/2:y<n/2))%n:0,81);}

```

Directly prints a solution in O(1) time.
> 7 votes

# Answer
# MATL, ~~33~~ ~~32~~ 27 bytes

```
`x,GZ@]1Z?tt!P!,w&TXds]h1>a

```

**Try it online!**

Semi-brute force, non-determistic approach:

1. Generate a random permutation of row positions
2. Generate a random permutation of column positions
3. Check that no queens share a diagonal or anti-diagonal
4. Repeat if necessary.

The obtained solution is random. If you run the code again you may get a different valid configuration. Running time is also random, but the longest test case (`n = 10`) finishes in about 30 seconds in TIO most of the time.
> 5 votes

# Answer
# Befunge, 122 bytes

```
&::2%-v>2*00g++00g%00g\-\00g\`*4>8#4*#<,#-:#1_$55+"Q",,:#v_@
/2p00:<^%g01\+*+1*!!%6g00-2g01\**!!%6g00-g012!:`\g01:::-1<p01

```

Try it online!

This is more or less based on the C solution by orlp.

**Explanation**

Read the number of queens, *q*, from stdin and calculate two variables for later use: `n = q - q%2`, and `hn = n/2`
Start the main loop, iterating *r*, the row number, from *q* down to 0, decrementing at the start of the loop, so the first *r* is *q* minus 1.
Calculate the offset of the queen in each row with the following formula:

```
offset = (n - (
  (hn <= r) * (2 - hn) * !!(n % 6) +
  (hn > r) * ((hn - 2) * !!(n % 6) + 1) +
  (y % hn * 2) + n
) % n) * (n > r)

```

Output *offset* space characters to indent the queen's position for the current row, plus one additional space just because it makes the output loop easier.
Output the `Q` for the queen, followed by a newline to move to the next row.
Test if *r* is zero, in which case we've reached the end of the board and can exit, otherwise we repeat the main loop again.
> 3 votes

# Answer
# Mathematica, 103 ~~108~~ ~~110~~ ~~117~~ bytes

-5 bytes for `DuplicateFreeQ` -\> `E!=##&@@@`

-7 bytes for `ReplacePart[Array[],]` -\> `SparseArray[]`

```
SparseArray[Thread@#&@@Select[Permutations@Range@#~Tuples~2,And@@(E!=##&@@@{#-#2,+##})&@@#&]->1,{#,#}]&

```

Return a 2D-array. It takes 2.76s to calculate `f[6]` and 135s for `f[7]`. (In the current version, `-` becomes `0` and `Q` to `1`.

The algorithm is similar to MATL answer but here the code is completely brute-force.
> 2 votes

# Answer
# C - 222 bytes

```
v,i,j,k,l,s,a[99];main(){for(scanf("%d",&s);*a-s;v=a[j*=v]-a[i],k=i<s,j+=(v=j<s&&(!k&&!!printf(2+"\n\n%c"-(!l<<!j)," #Q"[l^v?(l^j)&1:2])&&++l||a[i]<s&&v&&v-i+j&&v+i-j))&&!(l%=s),v||(i==j?a[i+=k]=0:++a[i])>=s*k&&++a[--i]);}

```

The code is not mine, but from the IOCCC. I hope I'm not breaking any rules. Also, this displays all solutions for N between 4 and 99. I'll try to get a TIO link later.
> 2 votes

# Answer
## Python 3, ~~204~~ 189 bytes

```
import itertools as p
n=int(input())
r=range(n)
b='.'*(n-1)+'Q'
for c in p.permutations(r):
 if len(set((x*z+c[x],z)for x in r for z in[1,-1]))==n+n:[print(*(b[x:]+b[:x]))for x in c];break

```

Brute force search through all permutations. I could remove the * and print the list comprehensions, but they look awful.

Output:

```
10
Q . . . . . . . . .
. . Q . . . . . . .
. . . . . Q . . . .
. . . . . . . Q . .
. . . . . . . . . Q
. . . . Q . . . . .
. . . . . . . . Q .
. Q . . . . . . . .
. . . Q . . . . . .
. . . . . . Q . . .

```

Slightly ungolfed:

```
import itertools as p
n=int(input())
r=range(n)
b='.'*(n-1)+'Q'
for c in p.permutations(r):
    if len(set( (x*z+c[x],z) for x in r for z in[1,-1] )) == n+n:
        [print(*(b[x:] + b[:x])) for x in c]
        break

```
> 1 votes

# Answer
# Jelly, ~~24~~ 21 bytes

```
,JŒc€IF€An/PC
ẊÇ¿=þRG

```

Try it online!

Assuming each queen are placed on separate rows, we only need to find the column indices to place each queen at to avoid conflicts, which can be found by generating a random permutation of `[1, 2, ..., n]` and testing it.

## Explanation

```
,JŒc€IF€An/PC  Helper. Input: permutation of [1, 2, ..., n]
 J             Enumerate indices, obtains [1, 2, ..., n]
,              Join
  Œc€          Find all pairs in each
     I         Calculate the difference of each pair
      F€       Flatten each
        A      Absolute value
               (We now have the distance in column between each queen and
                the distance in rows between each queen. If they are unequal,
                the queens do not conflict with each other)
         n/    Reduce using not-equals
           P   Product, returns 1 only if they are all unequal
            C  Complement
               Returns 1 when there is a conflict, else 0

ẊÇ¿=þRG  Main.  Input: n
Ẋ        Shuffle (When given an integer, it will shuffle [1, 2, ..., n])
 Ç¿      While the helper returns 1, continue shuffling
     R   Range, gets [1, 2, ..., n]
   =þ    Equality table (Generates the board as a matrix)
      G  Pretty-print the matrix

```
> 1 votes

# Answer
# Retina, 136 bytes

```
.+
$*

$_;$`Q¶
( +)\1( ?);
:$1;
:( +);\1\1
$1$1
:((   )+);( *)
 $1$1% $3$3
: ( +);( \1)?( *)
 $1 $1%$#2$* $#2$* $#2$* $1$3$3
( +)%\1?

```

Try it online! Port of @orlp's excellent C answer. Explanation:

```
.+
$*

```

Convert to unary, using spaces (there is a space after the `*`).

```
$_;$`Q¶

```

Create `N` rows with `N` spaces, a `;`, then `0..N-1` spaces, then a `Q`. The remaining stages apply to all rows.

```
( +)\1( ?);
:$1;

```

Integer divide `N` by 2. (Also wrap the result in `:;` to make it easier to anchor patterns.)

```
:( +);\1\1
$1$1

```

If the loop index equals `N/2*2`, then just leave that many spaces.

```
:((   )+);( *)
 $1$1% $3$3

```

If `N/2` is a multiple of 3, then take double the loop index plus one, modulo `N/2*2+1`.

```
: ( +);( \1)?( *)
 $1 $1%$#2$* $#2$* $#2$* $1$3$3

```

Otherwise, take double the loop index plus `(N/2-1)` plus an extra 3 in the bottom half of the board, modulo `N/2*2`.

```
( +)%\1?

```

Actually perform the modulo operation.
> 1 votes

# Answer
# Charcoal, 44 bytes

```
Ｎθ≔÷θ²ηＥθ◧Q⊕⎇⁼ι⊗ηι⎇﹪η³﹪⁺⁺⊗ι⊖η×³¬‹ιη⊗η﹪⊕⊗ι⊕⊗η

```

Try it online! Link is to verbose version of code. Another port of @orlp's excellent C answer.
> 1 votes

# Answer
# APL (Dyalog Unicode), 18 bytesSBCS

Full program prompting for `n` from stdin. Prints space-separated solution to stdout using `·` for empty squares and  for Queens.

```
⎕CY'dfns'
⊃queens⎕

```

Try it online!

`⎕CY'dfns'`**C**op**y** the "dfns" library

get input from stdin

`queens` find all truly unique Queens' solutions (no reflections or rotations)

pick the first solution
> 1 votes

# Answer
# Haskell, 145 bytes

The obvious brute force approach:

```
b=1>0
t[]=b
t(q:r)=all(/=q)r&&foldr(\(a,b)->(abs(q-b)/=a&&))b(zip[1..]r)&&t r
q n|y<-[1..n]=(\q->(' '<$[1..q])++"Q")<$>[x|x<-mapM(\_->y)y,t x]!!0

```

Try it online!
> 0 votes

# Answer
# , 49 bytes

```
i.=/0({(1-.@e.,)@(([:(=#\){.|@-}.)\."1)#])!A.&i.]

```

Try it online!

Brute force by testing all permutations of length *n*.
> 0 votes

# Answer
# Swift 5.9, 251 bytes

```
let f={n->[[Bool]] in
var q=[(Int,Int)](),z=0..<n
func d(_ r:Int){for c in z{if q.allSatisfy{(x,y)in !(x==r||y==c||abs(x-r)==abs(y-c))}{q+=[(r,c)]
d(r+1)
if q.count==n{break}
q.removeLast()}}}
d(0)
return z.map{r in z.map{c in q.contains{$0==(r,c)}}}}

```

The brute-force approach. I think.

This closure returns a 2D `Array` of `Bool`s. `true` means there's a queen there; `false` means that there's nothing there.
> 0 votes

# Answer
# Uiua, 29 characters

```
≡(+@@=⇡)⧻.-1∵⟨⌈÷2-|-⌊÷2⟩◿2.⇡.

```

Apparently any grid output is enough:

```
≡(=⇡)⧻.∵⟨-1⌈÷2-|-⌈÷2⟩◿2.⇡.

```

Try it here!
> 0 votes

---
Tags: code-golf, ascii-art, chess
---