65
\$\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\$
  • 1
    \$\begingroup\$ Related. \$\endgroup\$ – Leaky Nun Jul 31 '16 at 14:03
  • 5
    \$\begingroup\$ Can the output (as the return value from a function) be an array of lines? \$\endgroup\$ – Doorknob Jul 31 '16 at 14:55
  • \$\begingroup\$ @Doorknob I would say no. \$\endgroup\$ – Leaky Nun Jul 31 '16 at 14:56
  • \$\begingroup\$ @GeorgeGibson Yes. \$\endgroup\$ – Leaky Nun Jul 31 '16 at 17:36
  • \$\begingroup\$ @LeakyNun Is a trailing newline allowed? \$\endgroup\$ – Jakube Aug 1 '16 at 10:58

111 Answers 111

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\$
  • \$\begingroup\$ a=?A..?Z;puts a.map{|x|a.map{|y|x>y ?x:y}*""} \$\endgroup\$ – manatwork Aug 2 '16 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\$
  • \$\begingroup\$ It's got spaces in it after the edit \$\endgroup\$ – Blue Aug 2 '16 at 19:01
  • \$\begingroup\$ You are missing the letter N in the golfed version. \$\endgroup\$ – gwell Aug 2 '16 at 19:57
  • \$\begingroup\$ @gwell ooops, fixed! \$\endgroup\$ – Katenkyo Aug 3 '16 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\$

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

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)

Output

\$\endgroup\$
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
\$\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\$
  • \$\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 Nov 3 '16 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 Nov 11 '16 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\$ – Shaun Bebbers Nov 11 '16 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 Jan 9 '17 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\$ – Shaun Bebbers Jan 24 '17 at 10:20
1
\$\begingroup\$

Pepe, 88 85 bytes

REeEeeeeeErEeEeEEeEerEERREEEEEREEEereeREEEErerEEREEEEEEErereeerEEEEEeeEReeereeERrEree

Try it online!

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

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

\$\endgroup\$
  • 1
    \$\begingroup\$ You're better off without both using static, and only a using System;. Also you could just place it in the global namespace. Finally .. the modifiers internal and private are redundant. \$\endgroup\$ – asibahi Aug 2 '16 at 5:05
  • \$\begingroup\$ Yay I beat C#!! \$\endgroup\$ – user54200 Aug 5 '16 at 0:49
0
\$\begingroup\$

Pyke, 14 11 10 bytes

GFoj*Gj>ns

Try it here!

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

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

scratchblocks

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

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

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;}}
\$\endgroup\$
0
\$\begingroup\$

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(); }
\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I think you could move the char j into the loop after it. \$\endgroup\$ – Loovjo Nov 3 '16 at 12:14
  • \$\begingroup\$ for (char j = ...)? Moving declaration of loop control variable into inner loops makes code 3 bytes longer. \$\endgroup\$ – paldir Nov 3 '16 at 12:30
  • \$\begingroup\$ Oh sorry, my mistake \$\endgroup\$ – Loovjo Nov 3 '16 at 12:31
0
\$\begingroup\$

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)

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

PHP, 120 bytes

<?$a='ABCDEFGHIJKLMNOPQRSTUVWXYZ';$b=65;$c=26;while($c>0){echo str_repeat(chr($b++),26-$c).substr($a,26-$c--).'<br>';}?>
\$\endgroup\$
  • \$\begingroup\$ 1) 'AB...YZ' needs no quotes (and join(range(A,Z)) is another 10 bytes shorter). 2) You can remove the <? tag if You use -r. 3) >0 is unnecessary 4) for($c=26;$c;) instead of $c=26;while($c) 5) You should loop $c from 0 to 26 and use $c / $c++ instead of 26-$c / 26-$c--. 6) Try str_pad(substr($a,...),26,chr($b++),0) instead of the str_repeat. 7) Use "\n" instead of '<br>' 8) the closing ?> tag is unnecessary \$\endgroup\$ – Titus Nov 11 '16 at 12:29
  • \$\begingroup\$ 9) the curlys are unnecessary 10) You can find more gpolfing ideas at ideone.com/UUMshw to get this down to 70 bytes. Nice approach! \$\endgroup\$ – Titus Nov 11 '16 at 13:01
  • \$\begingroup\$ Found another 8 bytes: for($c=A;$c!=AA;)echo"\n",str_pad(join(range($c,Z)),26,$c++,0);, and use a physical linebreak for 62 bytes. \$\endgroup\$ – Titus Nov 11 '16 at 14:04
0
\$\begingroup\$

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

Pushy, 14 bytes

Non-competing as the language postdates the challenge.

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

Japt, 15 bytes

;B¬£B®<X?X:Z}÷

Test it online!

Japt, 12 + 1 = 13 bytes (non-competing)

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

Non-competing because this requires the -R flag, which was just added. Test it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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