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
    Commented 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
    Commented Jul 31, 2016 at 14:55
  • \$\begingroup\$ @Doorknob I would say no. \$\endgroup\$
    – Leaky Nun
    Commented Jul 31, 2016 at 14:56
  • 1
    \$\begingroup\$ I'm tried of the "here's text X. Print this" kind of challenges. \$\endgroup\$ Commented Nov 11, 2016 at 19:15
  • 1
    \$\begingroup\$ @BufferOverRead There's a good reason for the site having the kolmogorov-complexity tag. \$\endgroup\$
    – Makonede
    Commented May 25, 2021 at 23:11

130 Answers 130

1
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

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. \ns appear as spaces, this is the interpreter's error.

\$\endgroup\$
1
\$\begingroup\$

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

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
\$\endgroup\$
1
  • \$\begingroup\$ Why not iterate 65 to 90? \$\endgroup\$
    – manatwork
    Commented Aug 1, 2016 at 11:58
1
\$\begingroup\$

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
\$\endgroup\$
1
  • \$\begingroup\$ Nice approach. =tG does not only perform the assignment, it will also return the new value. So you can use this expression during the .[ statement and save one byte: WG.[hG26=tG \$\endgroup\$
    – Jakube
    Commented Aug 2, 2016 at 9:11
1
\$\begingroup\$

Ruby, 60 bytes

a=("A".."Z").to_a.join;(0..25).map{|i|puts(a[i]*i+a[i..-1])}
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Save a few bytes by doing [*a..b] instead of (a..b).to_a \$\endgroup\$
    – anon
    Commented Aug 2, 2016 at 6:48
  • 1
    \$\begingroup\$ Also, you can use 25.times instead of (0..25).each \$\endgroup\$
    – anon
    Commented Aug 2, 2016 at 6:49
  • 1
    \$\begingroup\$ Lastly, I think you can get rid of the parens around the arguments to puts if you have a space before them \$\endgroup\$
    – anon
    Commented Aug 2, 2016 at 6:50
1
\$\begingroup\$

F#, 70 bytes

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

Pretty straightforward.

\$\endgroup\$
5
  • \$\begingroup\$ Can you use their codepoints to replace 'A' and 'Z'? \$\endgroup\$
    – Leaky Nun
    Commented Aug 2, 2016 at 5:20
  • \$\begingroup\$ @LeakyNun I would need to cast to char so the net is 74 bytes : for i in 65..90 do(for j in 65..90 do printf"%c"(char<|max i j));printfn"" \$\endgroup\$
    – asibahi
    Commented Aug 2, 2016 at 5:32
  • \$\begingroup\$ What does printf"%c"65 do? \$\endgroup\$
    – Leaky Nun
    Commented Aug 2, 2016 at 5:35
  • \$\begingroup\$ throw an error. \$\endgroup\$
    – asibahi
    Commented Aug 2, 2016 at 5:36
  • \$\begingroup\$ Alright, thanks for teaching. \$\endgroup\$
    – Leaky Nun
    Commented Aug 2, 2016 at 5:36
1
\$\begingroup\$

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

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

\$\endgroup\$
1
\$\begingroup\$

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.
\$\endgroup\$
2
  • \$\begingroup\$ Nice answer, and welcome to the site! You can do map(chr,range(65,91)) to take a couple bytes off. \$\endgroup\$
    – DJMcMayhem
    Commented Aug 2, 2016 at 16:24
  • \$\begingroup\$ You could also take one byte off with y=0;exec"print x[y]*y+''.join(x[y:]);y+=1"*26 \$\endgroup\$
    – DJMcMayhem
    Commented Aug 2, 2016 at 16:26
1
\$\begingroup\$

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}
\$\endgroup\$
1
  • \$\begingroup\$ a=?A..?Z;puts a.map{|x|a.map{|y|x>y ?x:y}*""} \$\endgroup\$
    – manatwork
    Commented Aug 2, 2016 at 16:36
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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
\$\endgroup\$
3
  • \$\begingroup\$ It's got spaces in it after the edit \$\endgroup\$
    – Blue
    Commented Aug 2, 2016 at 19:01
  • \$\begingroup\$ You are missing the letter N in the golfed version. \$\endgroup\$
    – gwell
    Commented Aug 2, 2016 at 19:57
  • \$\begingroup\$ @gwell ooops, fixed! \$\endgroup\$
    – Katenkyo
    Commented Aug 3, 2016 at 19:44
1
\$\begingroup\$

Neoscript, 62 bytes (non-competing)

a='A:[]:'Zeach n=0:[]:25console:log(a[n]*n+a:slice(n):fuse());
\$\endgroup\$
1
  • \$\begingroup\$ Link to language is dead. Also, why is this non-competing? \$\endgroup\$ Commented Oct 31, 2020 at 0:58
1
\$\begingroup\$

Brachylog, 20 19 bytes

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

Try it online!

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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

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()
\$\endgroup\$
1
\$\begingroup\$

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

enter image description here

Scaled up 36x:

enter image description here

\$\endgroup\$
1
\$\begingroup\$

Befunge, 55 bytes

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

Try it online!

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
0
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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

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
\$\endgroup\$
1
  • \$\begingroup\$ It's possible to drop a byte using a|\a in place of a|/:a \$\endgroup\$
    – coltim
    Commented Mar 10, 2022 at 16:31
1
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

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

Lua, 83 bytes

Each iteration of the loop prints out the ith 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
\$\endgroup\$
1
1
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ Generally we include a byte count for code golf challenges. I have made some simple formatting edits to your answer to match how things are generally formatted however I left out the byte count because I am not familiar with scoring in Commodore 64. You can add one if you wish. It is generally paced in the title after the name of the language. Nice first post! \$\endgroup\$
    – Wheat Wizard
    Commented Nov 3, 2016 at 18:08
  • \$\begingroup\$ line 2 goto2? If I remember correctly, there´s no need to input a space after the line number, and i doesn´t need initialization. x is not really used; but I guess it should be somewhere. \$\endgroup\$
    – Titus
    Commented Nov 11, 2016 at 11:10
  • \$\begingroup\$ Keep forgetting that shift and enter for new line 2 end There is no need to put the line spaces after the line numbers but Commodore BASIC adds one anyway. You don't need to initialise i as zero, you are correct. x=0 is required as it's initialised on line 1 though, so there's a few bytes saved. To increase speed of Commodore BASIC, you should always initialise variables first. \$\endgroup\$ Commented Nov 11, 2016 at 11:19
  • \$\begingroup\$ You could use ? instead of print it I remember correctly. And every command can be abbreviated by using 2 characters, for example " e \$\endgroup\$
    – G B
    Commented Jan 9, 2017 at 21:18
  • \$\begingroup\$ Using ? instead of PRINT has no effect on Commodore BASIC other than when you are typing in the listing. If you try 0 ?"HELLO DAVE";:GOTO into a C64 and list it, the listing will show 0 PRINT"HELLO DAVE";:GOTO \$\endgroup\$ Commented Jan 24, 2017 at 10:20
1
\$\begingroup\$

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)}
\$\endgroup\$
1
\$\begingroup\$

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

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.