82
\$\begingroup\$

Print a Tabula Recta!

The Tabula Recta (sometimes called a 'Vigenere Table'), was created by Johannes Trithemius, and has been used in several ciphers, including all variants of Bellaso's Vigenere cipher and the Trithemius cipher. It looks like this:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZA
CDEFGHIJKLMNOPQRSTUVWXYZAB
DEFGHIJKLMNOPQRSTUVWXYZABC
EFGHIJKLMNOPQRSTUVWXYZABCD
FGHIJKLMNOPQRSTUVWXYZABCDE
GHIJKLMNOPQRSTUVWXYZABCDEF
HIJKLMNOPQRSTUVWXYZABCDEFG
IJKLMNOPQRSTUVWXYZABCDEFGH
JKLMNOPQRSTUVWXYZABCDEFGHI
KLMNOPQRSTUVWXYZABCDEFGHIJ
LMNOPQRSTUVWXYZABCDEFGHIJK
MNOPQRSTUVWXYZABCDEFGHIJKL
NOPQRSTUVWXYZABCDEFGHIJKLM
OPQRSTUVWXYZABCDEFGHIJKLMN
PQRSTUVWXYZABCDEFGHIJKLMNO
QRSTUVWXYZABCDEFGHIJKLMNOP
RSTUVWXYZABCDEFGHIJKLMNOPQ
STUVWXYZABCDEFGHIJKLMNOPQR
TUVWXYZABCDEFGHIJKLMNOPQRS
UVWXYZABCDEFGHIJKLMNOPQRST
VWXYZABCDEFGHIJKLMNOPQRSTU
WXYZABCDEFGHIJKLMNOPQRSTUV
XYZABCDEFGHIJKLMNOPQRSTUVW
YZABCDEFGHIJKLMNOPQRSTUVWX
ZABCDEFGHIJKLMNOPQRSTUVWXY

I frequently need this, but can't find it anywhere on the internet to copy and paste from. Because the square table is so long, and takes frigging ages to type, your code must be as short as possible.

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 = 86986; // 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 = 53406; // 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>

| improve this question | | | | |
\$\endgroup\$
  • \$\begingroup\$ Regarding rule 1: do we have to include each header for each function we use? \$\endgroup\$ – owacoder Jul 30 '16 at 15:59
  • \$\begingroup\$ I meant if we use printf, we need to include stdio.h, if isalpha is used, ctype.h is needed, etc. Is this correct? \$\endgroup\$ – owacoder Jul 30 '16 at 16:03
  • 3
    \$\begingroup\$ You should probably put "lowercase is allowed" in the challenge specification itself. Just so people are less likely to miss it if they don't see these comments. \$\endgroup\$ – Sherlock9 Jul 30 '16 at 18:25
  • 2
    \$\begingroup\$ do i have to print it or can i return a string/char array \$\endgroup\$ – downrep_nation Jul 30 '16 at 19:57
  • 1
    \$\begingroup\$ Thanks for the question for making me stay awake all night. (+1) \$\endgroup\$ – Anastasiya-Romanova 秀 Aug 22 '16 at 18:45

140 Answers 140

1
\$\begingroup\$

CJam, 15 bytes

'[,65>{_n(+}25*

Try it online!

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Pyth, 12 10 7 bytes

jP.:*2rG1 26
j.<LrG1 26
j.<LG26

Try it online!

It is a mistake to suddenly allow lowercase output.

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Pyke, 14 13 10 bytes

G26V
DtRh+

Try it here!

Ignore function output.

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ Really need a newline? \$\endgroup\$ – Erik the Outgolfer Jul 31 '16 at 16:10
  • 5
    \$\begingroup\$ @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ You really don't need to ask the author every single time you see whitespace in an answer whether that whitespace is necessary, especially if you don't know the language. Some whitespace in some languages is significant. And in a case like this, you could at least open the "Try it here" link, remove the linefeed and test your suggestion before posting it. \$\endgroup\$ – Martin Ender Jul 31 '16 at 16:58
  • \$\begingroup\$ @MartinEnder That's because I've got a real life, and I can't just know every programming language ever made... Also, some posts don't have "try it" links. \$\endgroup\$ – Erik the Outgolfer Jul 31 '16 at 17:02
  • 6
    \$\begingroup\$ @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Nobody expects you to know every language. The solution is not to learn every language but to stop wasting people's time with random untested golfing suggestions. \$\endgroup\$ – Martin Ender Jul 31 '16 at 17:06
  • \$\begingroup\$ @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ yes the newline does need to be there. \$\endgroup\$ – Blue Jul 31 '16 at 17:50
1
\$\begingroup\$

Python 3, 55 bytes

i=702
while i:i-=1;print(end=chr(10+(i%27and 80-i%26)))

Similar to my C answer: a single loop, printing the alphabet every 26 characters but with every 27th character replaced by a newline.

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

JavaScript, 86 bytes

"ABCDEFGHIJKLMNOPQRSTUVWXYZ".repeat(27).split("").map((n,m)=>m%27==26?"\n":n).join("")

Inspired by Anders Kaseorg's C solution

I decided this answer was different enough from the existing JS solutions to warrant its own answer.

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ you can use split`` instead of split("") to save some bytes :d \$\endgroup\$ – NTCG Jul 15 '18 at 21:55
1
\$\begingroup\$

Sesos, 39 bytes

Hexdump:

0000000: 2849b2 6f59be 65f996 e5cbd2 a041d3 eb61c7 6059be  (I.oY.e......A..a.`Y.
0000015: 65e9e7 765a96 a67bd8 315896 6f59fa f93d07         e..vZ..{.1X.oY..=.

Assembler:

add 65,fwd 1,add 26,fwd 1,add 26,fwd 1,add 26,fwd 1,add 10,rwd 1
jmp
  sub 1,rwd 1
  jmp
    sub 1,rwd 1,sub 1,rwd 1,put,add 1,fwd 1
    jmp,rwd 2,jnz
    rwd 1
    jmp,sub 26,fwd 1,add 26,rwd 3,jnz
    fwd 4
  jnz
  add 26,rwd 1
  sub 1,rwd 1,add 1,fwd 1
  jmp,rwd 2,jnz
  rwd 1
  jmp,sub 26,fwd 1,add 26,rwd 3,jnz
  fwd 6,put,rwd 1
jnz

Try it online!

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Python 3, 82 79 69 bytes

A simple nested loop that prints ''.joined lines one at a time. Golfing suggestions are welcome.

Edit: -13 bytes thanks to Leaky Nun.

for i in range(26):print("".join(chr(65+(i+j)%26)for j in range(26)))

Ungolfed:

for row in range(26):
    s = ""
    for column in range(26):
        s += chr(65 + (row+column) % 26)
    print(s)
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Emacs Lisp, 117 bytes

(let((s(mapcar'string(number-sequence ?A ?Z))))(dotimes(i 26)(message(apply'concat s))(setcdr(last s)(list(pop s)))))

Uses a list storing the alphabet and always appends the head to the tail. A more general approach would be the following function

(defun tabula-recta (glyphs)
  (dotimes (i (length glyphs))
    (message (apply 'concat glyphs))
    (setcdr (last glyphs) (list (pop glyphs)))))

which could be called in a similar fashion.

(tabula-recta (mapcar'string(number-sequence ?A ?Z)))
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Postscript, 153 bytes of code, 213 bytes for well-structured EPS

You might want your tabula recta in a form you can print out and put a Cardan grille on top of. This is an EPS (Encapsulated Postscript) file, which can be printed as is or embedded in a larger document at whatever scale you like.

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 187 258
/Courier findfont 12 scalefont setfont
0 1 25{dup neg 25 add 10 mul 0 exch moveto
0 1 25{1 index add 26 mod 65 add( )dup 0 4 3 roll put show}for
pop}for
showpage

PostScript is really thorough about its reverse Polish notation, even more so than Forth. This looks cryptic, but hasn't been obfuscated at all, except by minimizing whitespace. The actual computation...

0 1 25 {
    dup
    neg 25 add 10 mul 0 exch moveto
    0 1 25 {
        1 index add 26 mod 65 add
        ( ) dup 0 4 3 roll put
        show
    } for
    pop
} for

... is pretty much the most straightforward way to do this in this language. ("1 string" might be preferred to "( )" but that's longer.)

I used Courier because it's the fixed-width font included in the original core font set, and therefore doesn't have to be embedded in the file.

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Actually, 15 bytes

5Pτr`úi(}akΣ`Mi

Try it online!

Explanation:

5Pτr`úi(}akΣ`Mi
5Pτr             range(26)
    `úi(}akΣ`M   for each element n:
     úi(           lowercase English alphabet, flatten, move n to top
        }          rotate stack left n times
         akΣ       invert stack, push as list, concatenate
              i  flatten
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Java 1.8, 106 101 bytes

Simply prints every character as a byte, followed by a line feed (which forces a flush on the line-buffered System.out stream), by using mod operations.

interface C{static void main(String[]a){for(int i=-1;++i<702;)System.out.write(i%27>25?10:i%26+65);}}

Run it.

Shaved off a few bytes thanks to @KevinCruijssen

Initially my attempts had a pre-defined alphabet string, since I had a hard time generating the sequence with less characters. The shortest version I managed to find basically runs a 26-character window over a string that contains the alphabet twice:

151 bytes

class G{public static void main(String[]a){String s="ABCDEFGHIJKLMNOPQRSTUVWXYZ";s+=s;int i=0;while(i<26){System.out.println(s.substring(i,++i+25));}}}

Run it

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ @KevinCruijssen: Actually, no. print() would print the integer value of i, whereas write() prints the byte value (and thus a character). :) You can of course use print() to print the character value, but that would require an extra 6 bytes for the cast ((char)). \$\endgroup\$ – MH. Aug 1 '16 at 12:31
  • \$\begingroup\$ Yeah, realized that soon after I made my comment and therefore deleted it. :) Never really used .write tbh, and I'm kinda confused why class M{public static void main(String[]a){int t=88;System.out.write(t);}} doesn't print anything unless I'm adding a System.out.flush(); while your answer works just fine without.. \$\endgroup\$ – Kevin Cruijssen Aug 1 '16 at 12:40
  • 1
    \$\begingroup\$ Ah, that's why your comment disappeared as soon as I posted mine. :) Your question is answered by write()'s doc: "If the byte is a newline and automatic flushing is enabled then the flush method will be invoked." So the reason the answer works is because it writes a newline character at the end of every line and auto flush is enabled for System.out(search for "line buffered"). \$\endgroup\$ – MH. Aug 1 '16 at 12:50
  • \$\begingroup\$ Thanks for the explanation! There are already like 3-4 Java answers for this challenge, but yours is the shortest and to the point. Btw, you can golf it by 2 bytes by removing the { and } from the for-loop, since you only have one line in it. Also, you don't have to include the class & main method in your byte-count unless the question states otherwise. Since it states: "Each submission should be either a full program or function.", just void f(){for(int i=-1;++i<702;)System.out.write(i%27>25?10:i%26+65);} would suffice as answer. \$\endgroup\$ – Kevin Cruijssen Aug 1 '16 at 12:58
  • \$\begingroup\$ Also, I just notice you are new here on PPCG. So welcome! :) You might also find Tips for Golfing in Java an interesting post to take a look at. \$\endgroup\$ – Kevin Cruijssen Aug 1 '16 at 13:00
1
\$\begingroup\$

Javascript 98 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ";for (var i = 0; i < 26; i++) {console.log(s);s=s+s[0];s.substr(1);}

try it yourself at: https://jsfiddle.net/dL0vg3cL/1/
sorry i don't know how to do the character count

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ First, all answers require the byte count in the title. Also, s=s+s.charAt(0) can be written as s+=s[0]. You don't need the var and you have too much whitespace. This should bring down your byte count to a more competitive number. \$\endgroup\$ – Ismael Miguel Aug 2 '16 at 18:27
  • \$\begingroup\$ @IsmaelMiguel originally there was no white space, someone edited it, and I will use s=s+s[0] thanks for the tip \$\endgroup\$ – Mohammad Ali Aug 2 '16 at 18:29
  • \$\begingroup\$ You can revert the edit. Then, you simply add 4 spaces at the beginning of your code. This will format it properly. Also, you can use stack snippets to let us try your code, without an external link to jsfiddle. \$\endgroup\$ – Ismael Miguel Aug 2 '16 at 18:31
  • \$\begingroup\$ @IsmaelMiguel done and i don't know how to use stack snippets on mobile \$\endgroup\$ – Mohammad Ali Aug 2 '16 at 18:34
1
\$\begingroup\$

Perl 5, 39 36 bytes

print$_%27?chr$_%26+65:$/for-26..675

Similar to my C answer: a single loop, printing the alphabet every 26 characters but with every 27th character replaced by a newline.

Thanks to Dom Hastings for −2 bytes.

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

C#, 157 Chars

class P{static void Main(){string x="ABCDEFGHIJKLMNOPQRSTUVWXYZ";for(int i=0;i<x.Length;i++)Console.WriteLine(x.Substring(i,x.Length-i)+x.Substring(0,i));}}
| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ You have needless spaces and, apparently, needless braces. \$\endgroup\$ – asibahi Aug 3 '16 at 8:05
1
\$\begingroup\$

><>, 44 bytes

0:1[\ao]1+:dd+=?;!
$l(?\:1+dd+:@%
ol?!\{"A"+

Try it online!

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Cheddar, 79 bytes

(|>26).map(l->String.letters.slice(l)+String.letters.slice(0,l)).vfuse.slice(1)

Pretty ugly answer. I would of had a much nicer answer if I fixed cycle in time:

(|>26).map(String.letters.cycle).vfuse
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Ruby, 75 42 bytes

a=('A'..'Z').to_a;l=a.length;l.times {l.times {|i|$><<a[i]};a.rotate!;puts}

a=*?A..?Z;26.times {puts a.join;a.rotate!}
| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ Rotate! I was searching so long for this method, but I couldn't remember its name. \$\endgroup\$ – IMP1 Feb 17 '17 at 10:41
1
\$\begingroup\$

Batch, 94 bytes

@set a=ABCDEFGHIJKLMNOPQRSTUVWXYZ
@for /l %%i in (0,1,25)do @call echo %%a:~%%i%%%%a:~0,%%i%%
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Brachylog, 19 16 bytes

25yeN,@A:N:$(iw@Nw\
@A~c[A:B]rcw@Nw\

Try it online!

Explanation of the 16-byte solution

@A~c[A:B]rcw@Nw\
@A~c[A:B]            @A is in the form of A+B.  (choice point)
                     (@A == 'abcdefghijklmnopqrstuvwxyz')
         rcw         Write B+A to STDOUT.
            @Nw      Write '\n' to STDOUT.
               \     Backtrack to last choice point and
                     make the next choice until there is
                     no more choice left.

Explanation of the 19-byte solution

25yeN,@A:N:$(iw@Nw\
25yeN                N is a number between 0 and 25 inclusive. (choice point)
      @A:N:$(iw      @A left-rotated N times, print it to STDOUT.
                     (@A == 'abcdefghijklmnopqrstuvwxyz')
               @Nw   Write '\n' to STDOUT.
                  \  Backtrack to last choice point and
                     make the next choice until there is
                     no more choice left.
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

VBA, 71 bytes 70 bytes

Run the below code in the Immediate Window

for j=1to 26:a="ABCDEFGHIJKLMNOPQRSTUVWXYZ":?mid(a,j)&left(a,j-1):next

Output:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZA
CDEFGHIJKLMNOPQRSTUVWXYZAB
DEFGHIJKLMNOPQRSTUVWXYZABC
EFGHIJKLMNOPQRSTUVWXYZABCD
FGHIJKLMNOPQRSTUVWXYZABCDE
GHIJKLMNOPQRSTUVWXYZABCDEF
HIJKLMNOPQRSTUVWXYZABCDEFG
IJKLMNOPQRSTUVWXYZABCDEFGH
JKLMNOPQRSTUVWXYZABCDEFGHI
KLMNOPQRSTUVWXYZABCDEFGHIJ
LMNOPQRSTUVWXYZABCDEFGHIJK
MNOPQRSTUVWXYZABCDEFGHIJKL
NOPQRSTUVWXYZABCDEFGHIJKLM
OPQRSTUVWXYZABCDEFGHIJKLMN
PQRSTUVWXYZABCDEFGHIJKLMNO
QRSTUVWXYZABCDEFGHIJKLMNOP
RSTUVWXYZABCDEFGHIJKLMNOPQ
STUVWXYZABCDEFGHIJKLMNOPQR
TUVWXYZABCDEFGHIJKLMNOPQRS
UVWXYZABCDEFGHIJKLMNOPQRST
VWXYZABCDEFGHIJKLMNOPQRSTU
WXYZABCDEFGHIJKLMNOPQRSTUV
XYZABCDEFGHIJKLMNOPQRSTUVW
YZABCDEFGHIJKLMNOPQRSTUVWX
ZABCDEFGHIJKLMNOPQRSTUVWXY
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Pushy, 5 bytes

Non-competing as the language postdates the challenge, but I though I'd post it as it's the same length as the 05AB1E answer...

AL:"{

Try it online!

This takes advantages of cyclic shifting:

A      \ Push the uppercase alphabet, as a list of charcodes.
 L:    \ Length (yields 26) times do:
   "   \   Print the characters
    {  \   Cyclically shift left, once.
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Perl 6, 40 bytes

say [~] (|("A".."Z")xx 2)[^26+$_]for ^26

Joshua's answer already shows the canonical way to do this in Perl 6, but I thought it might be interesting to show a solution that doesn't use the rotate built-in.

How it works

                                 for ^26  # For each index from 0 to 25:
           "A".."Z"                       #   Generate the alphabet.
         |("A".."Z")                      #   Slip it into the outer list.
                    xx 2                  #   Repeat it, yielding a flat list of 52 characters.
        (               )[      ]         #   Index this list using:
                          ^26             #      The range from 0 to 25,
                             +$_          #      with the loop counter added to both endpoints.
    [~]                                   #   Concatenate the result.
say                                       #   Print it, followed by a newline.
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Racket 126 bytes

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

Ungolfed:

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

Testing:

(f)

Output:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZA
CDEFGHIJKLMNOPQRSTUVWXYZAB
DEFGHIJKLMNOPQRSTUVWXYZABC
EFGHIJKLMNOPQRSTUVWXYZABCD
FGHIJKLMNOPQRSTUVWXYZABCDE
GHIJKLMNOPQRSTUVWXYZABCDEF
HIJKLMNOPQRSTUVWXYZABCDEFG
IJKLMNOPQRSTUVWXYZABCDEFGH
JKLMNOPQRSTUVWXYZABCDEFGHI
KLMNOPQRSTUVWXYZABCDEFGHIJ
LMNOPQRSTUVWXYZABCDEFGHIJK
MNOPQRSTUVWXYZABCDEFGHIJKL
NOPQRSTUVWXYZABCDEFGHIJKLM
OPQRSTUVWXYZABCDEFGHIJKLMN
PQRSTUVWXYZABCDEFGHIJKLMNO
QRSTUVWXYZABCDEFGHIJKLMNOP
RSTUVWXYZABCDEFGHIJKLMNOPQ
STUVWXYZABCDEFGHIJKLMNOPQR
TUVWXYZABCDEFGHIJKLMNOPQRS
UVWXYZABCDEFGHIJKLMNOPQRST
VWXYZABCDEFGHIJKLMNOPQRSTU
WXYZABCDEFGHIJKLMNOPQRSTUV
XYZABCDEFGHIJKLMNOPQRSTUVW
YZABCDEFGHIJKLMNOPQRSTUVWX
ZABCDEFGHIJKLMNOPQRSTUVWXY
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Japt, 10 9 bytes

8 bytes of code, +1 for the -R flag.

26Æ;BéXn

Try it online!

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

tcl, 75

time {puts -nonewline [format %c [expr ([incr i]%27)?($i-1)%26+65:10]]} 702

Can be seen running on: http://rextester.com/live/BNZ46923

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Python 2, 58 bytes

a=bytearray(range(65,91))*2
exec'print a[:26];a=a[1:];'*26

Try it online!

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Python 2, 60 bytes

s = string.uppercase
for i in range(0,26):print s[i:]+s[:i]

Needs the string library to run.

| improve this answer | | | | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Dark Lord, Sir - I have some good news and some bad - bad news: you need to include import string if you are using the external string library. Good news: you can drop 2 bytes by condensing s = string... to s=string... AND I have prepared a TIO Link for you, Dark Lord, Sir. \$\endgroup\$ – Taylor Scott Jul 22 '17 at 18:09
1
\$\begingroup\$

Recursiva, 13 bytes

{("P+}J''_Q(}

Try it online!

Explanation

{("P+}J''_Q(}
{             - For each
 (            - Upper-case alphabet yield
  "           - Iteration command begin
   P          - Print
    +         - Concatenate 'BCDE...XYZA'
     }        - Current element say 'B' (2nd iteration) 
      J''     - join with nothing 'CDE...XYZA'
         _    - Reverse; ['CDEF.... XYZ', 'A']
          Q(} - Split ( at }'i.e. B'; ['A','CDEF....XYZ']
| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 59 bytes

(0..25).map{i->(0..25).map{print('A'+(it+i)%26)}
println()}

Beautified

    (0..25).map{i->
        (0..25).map { print('A' + (it+i)%26) }
        println()
    }

Test

fun x() =
(0..25).map{i->(0..25).map{print('A'+(it+i)%26)}
println()}

fun main(args: Array<String>) {
    x()
}

TryItOnline

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

Pyth, 11 10 7 bytes

-1 based off Jakube's idea.

-3 from Jakube

I'd like to see how far down this could be golfed. I'm guessing it'll have mapping somewhere in there.

Also, I'm taking a stab in the dark assuming that non-fixed-input s need not support input. If there is a meta page, could somebody link it?

VG=+t
GN

Explanation:

         (G=lowercase alphabet)
VG       Print the alphabet; For in the all but the last character of the alphabet:
  =+t    (New line = print next arg + input which I assume is empty)
     GN  Append the first character of G (the current index) to the end of G. This is pretty neat, while returning the value, it does two things: print the tabula, and modify the G variable.

Try it online!

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ There are already shorter Pyth solutions here, but this was a short golf I immediately found for your solution: VG=+t<newline>GhG \$\endgroup\$ – Jakube Sep 18 '17 at 7:03
  • \$\begingroup\$ Actually, this is even shorter: VG=+t<newline>GN \$\endgroup\$ – Jakube Sep 18 '17 at 7:05
  • \$\begingroup\$ @Jakube Neither of these work, as they start at "bcde..." and not "abcd...", nice try though! \$\endgroup\$ – Stan Strum Sep 18 '17 at 10:23
  • \$\begingroup\$ No, they don't: TryItOnline \$\endgroup\$ – Jakube Sep 18 '17 at 12:33
  • \$\begingroup\$ @Jakube that's something I didn't know worked \$\endgroup\$ – Stan Strum Sep 18 '17 at 13:00

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.