69
\$\begingroup\$

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>

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Related. \$\endgroup\$
    – Leaky Nun
    Jul 31, 2016 at 14:03
  • 5
    \$\begingroup\$ Can the output (as the return value from a function) be an array of lines? \$\endgroup\$
    – Doorknob
    Jul 31, 2016 at 14:55
  • \$\begingroup\$ @Doorknob I would say no. \$\endgroup\$
    – Leaky Nun
    Jul 31, 2016 at 14:56
  • 1
    \$\begingroup\$ I'm tried of the "here's text X. Print this" kind of challenges. \$\endgroup\$ Nov 11, 2016 at 19:15
  • 1
    \$\begingroup\$ @BufferOverRead There's a good reason for the site having the kolmogorov-complexity tag. \$\endgroup\$
    – Makonede
    May 25, 2021 at 23:11

129 Answers 129

1
2 3 4 5
66
\$\begingroup\$

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.
\$\endgroup\$
21
  • 23
    \$\begingroup\$ this made me laugh, you should post on meta sking how to count this \$\endgroup\$ Jul 31, 2016 at 15:26
  • 20
    \$\begingroup\$ A fair count for this would be 45: (1) type A1:Z26 in the Name Box (left of the formula bar) [7 bytes]; (2) type =CHAR(64+MAX(COLUMN(),ROW()))+enter in the formula bar [30 bytes]; (3) type Alt E I D Alt E I R to fill the selected range [8 bytes]. Total 7+30+8= 45. \$\endgroup\$
    – Joffan
    Jul 31, 2016 at 17:41
  • 8
    \$\begingroup\$ I don't think that counting autocomplete as as a lesser amount of bytes. Then I could arguably shrink my java down by arguing netbeans autcomplete. I think the measure by keystrokes 46 keystrokes is more fair \$\endgroup\$ Jul 31, 2016 at 18:38
  • 3
    \$\begingroup\$ @rohan I, for one, would be perfectly fine with you calling Java + autocomplete a language. \$\endgroup\$ Aug 1, 2016 at 16:02
  • 6
    \$\begingroup\$ @Joffan [A1:Z26]="=CHAR(64+MAX(COLUMN(),ROW()))" is 40 bytes and is still elegant \$\endgroup\$ Aug 22, 2016 at 13:00
44
\$\begingroup\$

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…

enter image description here

\$\endgroup\$
4
  • 5
    \$\begingroup\$ what. the. hell. is. this. godforsaken. magic. \$\endgroup\$ Aug 4, 2016 at 21:27
  • 1
    \$\begingroup\$ What help page are you opening? When I do h<_↵ It brings me to :help at_t \$\endgroup\$
    – DJMcMayhem
    Aug 23, 2016 at 19:34
  • \$\begingroup\$ I’m opening v_b_<_example in Vim 7.4 for Cygwin. \$\endgroup\$
    – Lynn
    Aug 23, 2016 at 19:37
  • \$\begingroup\$ @haneefmubarak Yes, it is the magic of Vim. \$\endgroup\$
    – Chromium
    Jul 15, 2018 at 2:07
28
\$\begingroup\$

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.
\$\endgroup\$
5
  • 7
    \$\begingroup\$ Argh, ninja'd by a few minutes... That alternative wouldn't have helped since the chain would fork. \$\endgroup\$
    – Dennis
    Jul 31, 2016 at 16:10
  • \$\begingroup\$ Stupid question, but if this is 6 bytes, what character set is it in? \$\endgroup\$
    – Mr Lister
    Aug 2, 2016 at 9:38
  • \$\begingroup\$ @MrLister: I added a link to the Jelly code page in the answer’s title. \$\endgroup\$
    – Lynn
    Aug 2, 2016 at 10:15
  • \$\begingroup\$ Join by linefeed is Y. \$\endgroup\$ Oct 26, 2016 at 10:01
  • \$\begingroup\$ @Pietu1998 I think Y post dates the challenge though \$\endgroup\$ Aug 29, 2017 at 22:21
19
\$\begingroup\$

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!

\$\endgroup\$
0
17
\$\begingroup\$

brainfuck, 103 96 95 91 87 bytes

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

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

\$\endgroup\$
17
\$\begingroup\$

///, 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 As.

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.

\$\endgroup\$
4
  • \$\begingroup\$ Damn, this is clever. Nice work. :) Any ideas for a solution along these lines to the tabula recta challenge? \$\endgroup\$ Aug 1, 2016 at 11:36
  • \$\begingroup\$ @MartinEnder No, not yet. I'll look at it in the evening. Extended the lunch break already to a full hour (twice as much a usual) because of this challenge. \$\endgroup\$
    – Jakube
    Aug 1, 2016 at 11:43
  • \$\begingroup\$ I figured something out (with a lot of help from your ideas, especially the way you modify subsequent instructions to process one character after the other). \$\endgroup\$ Aug 2, 2016 at 7:57
  • 1
    \$\begingroup\$ -1 byte (I just randomly deleted that character, no idea why this works) \$\endgroup\$
    – Fmbalbuena
    Nov 21, 2023 at 2:07
11
\$\begingroup\$

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.

\$\endgroup\$
2
  • 5
    \$\begingroup\$ Congrats on 10k! \$\endgroup\$
    – xenia
    Jul 31, 2016 at 16:05
  • \$\begingroup\$ 44 bytes lowercase \$\endgroup\$
    – att
    Sep 17, 2020 at 5:56
9
\$\begingroup\$

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!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Congratz for 100k! :) \$\endgroup\$
    – Yytsi
    Aug 1, 2016 at 10:00
8
\$\begingroup\$

///, 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.

\$\endgroup\$
1
  • \$\begingroup\$ I really need to learn this language... \$\endgroup\$
    – user53406
    Jul 31, 2016 at 19:34
8
\$\begingroup\$

Haskell, 35 bytes

a=['A'..'Z']
unlines$(<$>a).max<$>a
\$\endgroup\$
8
\$\begingroup\$

Python 2, 59 bytes

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

Test it on Ideone.

\$\endgroup\$
7
\$\begingroup\$

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
\$\endgroup\$
1
  • \$\begingroup\$ A new user has a suggestion to golf your answer here \$\endgroup\$
    – user41805
    Nov 12, 2016 at 7:35
7
\$\begingroup\$

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.

\$\endgroup\$
7
\$\begingroup\$

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

\$\endgroup\$
10
  • \$\begingroup\$ I actually dont because im also using Console which would require me to type System.Console which nobody does. \$\endgroup\$ Jul 31, 2016 at 14:35
  • \$\begingroup\$ consider setting j = 97 and i beilieve (char)j+i+"" may work and be shorter, but I only know java so i'm not sure \$\endgroup\$ Jul 31, 2016 at 15:29
  • \$\begingroup\$ j is used as an offset for the first character. if i do j=97 i need to do j++ aswell \$\endgroup\$ Jul 31, 2016 at 17:24
  • 2
    \$\begingroup\$ what's sad is that its ~50% longer than the brainfuck solution \$\endgroup\$ Aug 1, 2016 at 2:06
  • 1
    \$\begingroup\$ This doesn't output the correct answer when I run it, can you add a link to try it? \$\endgroup\$ Aug 2, 2016 at 10:22
7
\$\begingroup\$

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
\$\endgroup\$
6
\$\begingroup\$

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.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Very clever use of gallery \$\endgroup\$
    – Suever
    Jul 31, 2016 at 14:51
  • 2
    \$\begingroup\$ Too bad there's` no gallery('maxij',...), huh? ;) \$\endgroup\$ Jul 31, 2016 at 14:59
  • \$\begingroup\$ @MartinEnder Totally! :-) BTW, I'm waiting for the Mathematica builtin... \$\endgroup\$
    – Luis Mendo
    Jul 31, 2016 at 15:04
  • \$\begingroup\$ You're in for a long wait, this is a string-based challenge. :P \$\endgroup\$ Jul 31, 2016 at 15:07
6
\$\begingroup\$

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

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Just as before, it's shorter to turn exec into for to use the current character being iterated over: for c in a:a[:i]=[c]*i;i+=1;print'%c'*26%tuple(a). \$\endgroup\$
    – xnor
    Aug 1, 2016 at 0:20
  • \$\begingroup\$ Whoa, that's great :D \$\endgroup\$
    – ABcDexter
    Aug 2, 2016 at 7:15
6
\$\begingroup\$

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 -joined 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
\$\endgroup\$
6
\$\begingroup\$

R, 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.

\$\endgroup\$
5
\$\begingroup\$

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.
\$\endgroup\$
0
4
\$\begingroup\$

Octave, 26 bytes

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

Sample run on ideone.

\$\endgroup\$
2
  • \$\begingroup\$ Very nice! I keep forgetting the [...,''] trick \$\endgroup\$
    – Luis Mendo
    Jul 31, 2016 at 16:01
  • 1
    \$\begingroup\$ @LuisMendo It really only saves 1 byte, but it's flashy! :D \$\endgroup\$
    – beaker
    Jul 31, 2016 at 16:08
4
\$\begingroup\$

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

\$\endgroup\$
0
4
\$\begingroup\$

Javascript ES6, 81 bytes

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

Self-explanatory.

\$\endgroup\$
11
  • \$\begingroup\$ Would something like [..."LETTERS"].map be shorter? \$\endgroup\$
    – bren
    Jul 31, 2016 at 15:43
  • \$\begingroup\$ That was my original approach, but it's 2 bytes longer. \$\endgroup\$ Jul 31, 2016 at 15:44
  • \$\begingroup\$ That was the approach I thought when I saw this challenge \$\endgroup\$
    – bren
    Jul 31, 2016 at 15:45
  • \$\begingroup\$ Generally, it's better to use replace over map when iterating over strings char-by-char. \$\endgroup\$ Jul 31, 2016 at 15:46
  • 1
    \$\begingroup\$ In a.slice(y) where does the variable a come from? \$\endgroup\$
    – gcampbell
    Jul 31, 2016 at 17:22
4
\$\begingroup\$

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})
\$\endgroup\$
2
  • \$\begingroup\$ I left a comment on @plannapus' answer redirecting him to your answer \$\endgroup\$
    – user41805
    Nov 12, 2016 at 7:35
  • \$\begingroup\$ This is good but there's still a shorter approach \$\endgroup\$
    – Giuseppe
    Oct 6, 2017 at 12:57
4
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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

\$\endgroup\$
0
3
\$\begingroup\$

𝔼𝕊𝕄𝕚𝕟, 12 chars / 15 bytes

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

Try it here (Chrome Canary only).

Basically a port of my ES6 answer.

\$\endgroup\$
5
  • \$\begingroup\$ I'm not getting ZZZZZZZZZZZZZZZ... for the bottom line. Only getting one Z. \$\endgroup\$ Aug 1, 2016 at 17:43
  • \$\begingroup\$ What browser are you using? \$\endgroup\$ Aug 1, 2016 at 18:19
  • 1
    \$\begingroup\$ In fact, @cwallenpoole, screenshot of the code running in Chrome Canary. \$\endgroup\$ Aug 2, 2016 at 1:39
  • \$\begingroup\$ +1 to get rid of that negative score. Doesn't work in Google Chrome, but it does work in FireFox. \$\endgroup\$ Aug 2, 2016 at 7:13
  • \$\begingroup\$ Tried FF too, but it didn't work. Oh well. Removed -1. \$\endgroup\$ Aug 2, 2016 at 14:50
3
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ I m being nitpicky a bit but this output a matrix, not the exact text desired (i. e. the desired output shouldn't have all the quotes, spaces, rownames, colnames etc). \$\endgroup\$
    – plannapus
    Aug 22, 2016 at 13:10
3
\$\begingroup\$

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 ;_;

\$\endgroup\$
1
  • \$\begingroup\$ I thought something like 65@"90 works for String.letters \$\endgroup\$ Aug 4, 2016 at 7:27
1
2 3 4 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.