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

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

139 Answers 139

1
\$\begingroup\$

uBASIC, 68 bytes

That pesky Chr$() and adding extra spaces forces the use of Left$() for +7 Bytes

0ForI=0To25:ForJ=0To25:?Left$(Chr$(65+(I+J)Mod 26),1);:NextJ:?:NextI

Try it online!

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

Pyth, 9 bytes

VlG.<rG1N

Try it online!

If lowercase is allowed, the code can be shortened to 7 bytes:

VlG.<GN

which ties Leaky Nun's (also lowercase) answer.

\$\endgroup\$
  • \$\begingroup\$ The accepted answer is lowercase, which implies that it is allowed. \$\endgroup\$ – Jo King Mar 1 '18 at 6:05
1
\$\begingroup\$

Stax, 5 bytes

É,=■♦

Run and debug online!

Explanation

Bytes counted in CP437.

Uses the unpacked version to explain.

VAgl|(
VA        The alphabet
  gl      Iterate until a loop is found, print each iteration on a separate line
    |(    Left rotate by 1 element
\$\endgroup\$
  • 1
    \$\begingroup\$ Unpacked 5 bytes: VA:(m \$\endgroup\$ – wastl Jul 5 '18 at 17:53
1
\$\begingroup\$

brainfuck, 137 135 128 bytes

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

Try it online!

How it Works:

++[[+<]>+>++]<  Generates the number 27
[[-<+>>+<]>-]   Copies and decrements the 27 until it is 0
                Tape looks like 27 26 25 24 23 21 ... 3 2 1 0 0'
<----[<[+<]>[>]<----] Adds 63 to each number, making them correspond to the uppercase alphabet and @
<, Pop the excess @
There are going to be two strings separated by a 0
The second is intitially blank
<[ While the first string exists
   [[.<]<] Print the two strings of characters
   >>[[>]>]<< Go to the start of the first string
   Copy the first character of the first string to the end of the second string
   [[<]<[<]<+>>[>]>[>]<-]<[<]<[<]<[->+<] 
   ++++++++++., Print a newline
   >[>]>[>]< Go to the start of the first string
] Ends if the first string is empty
\$\endgroup\$
1
\$\begingroup\$

Red, 66 65 bytes

repeat n 26[repeat m 26[prin to-char n + m - 2 % 26 + 65]print""]

Try it online!

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

Powershell, 54 bytes

-join[char[]](0..702|%{if($_%27){--$_%26+65}else{10}})
\$\endgroup\$
  • \$\begingroup\$ There is the cool solution from @Joey \$\endgroup\$ – mazzy Jul 5 '18 at 19:07
1
\$\begingroup\$

Small Basic, 117 bytes

Script that takes no input and outputs to the TextWindow object

For I=0To 25
s=""
For J=0To 25
s=s+Text.GetCharacter(65+Math.Remainder(I+J,26))
EndFor
TextWindow.WriteLine(s)
EndFor

Try it at SmallBasic.com! Requires Silverlight and thus must be opened with IE

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

Pepe, 79 bytes

rEeEeeeeeEREeEeEEeEeREERrEEEEErEEEeReerEEEEREEreeereeErRrEEEEEEEREEEEEEEReereee

Try it online!

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

Brachylog, 11 bytes

25⟦{;Ạ↺₍ẉ}ᵐ

Try it online!

Full program, as it wouldn't be possible for a Brachylog predicate to meet this challenge's restriction on functions (main predicate is defined as the first one, so a call on a later line would simply be ignored), and it's probably easiest to separate it all off into lines with rather than anything else anyhow. Prints the table in lower case with a trailing newline.

25⟦            Range from 0 to 25 inclusive.
   {     }ᵐ    For every number in that range,
    ;Ạ         pair it with the lowercase alphabet,
      ↺₍       rotate the second element of the pair left by the first,
        ẉ      and print it with a newline.
\$\endgroup\$
1
\$\begingroup\$

T-SQL, 155 154 bytes

~Removed semicolon to save 1 byte.

It isn't as short as the other T-SQL answer, but I wanted to create a recursive SQL sample, and only have SQL server installed.

WITH f AS(SELECT 1n,CAST('abcdefghijklmnopqrstuvwxyz'AS VARCHAR(MAX))v UNION ALL SELECT n+1,RIGHT(v,LEN(v)-1)+LEFT(v,1)v FROM f WHERE n<26)SELECT v FROM f

~Added link to test environment~

https://rextester.com/CVII57986

\$\endgroup\$
  • \$\begingroup\$ Hello and welcome to PPCG. I currently cannot test your solution and therefore simply trust you that this answer is valid. It would be helpful if you could link to an online testing environment, though you do not have to. \$\endgroup\$ – Jonathan Frech Mar 1 at 17:29
  • 1
    \$\begingroup\$ Good point, added a permalink. \$\endgroup\$ – Aesais Mar 1 at 17:37
1
\$\begingroup\$

Gol><>, 21 bytes

`Z9sF:M|lFlKasRo}ao|;

2 bytes knocked off courtesy of JoKing, who also designed a version that has a leading newline (click here for it)

Try it online!

Gol><>, 23 bytes

`Z9sF:M|asFasKasRo}ao|;

Golfed off a ton of bytes by pushing the letters of the alphabet in! I'm going to try to make the output code smaller.

Try it online!

Old version, 44 bytes

"ABCDEFGHIJKLMNOPQRSTUVWXYZ"rasFasKasRo}ao|;

This is a brute force method of doing this, but I will golf it down some more.

Try it online!

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

Japt-R, 14 8 bytes

;26ÆBéYn

-6 bytes thanks to @Shaggy!

Try it Online!

\$\endgroup\$
  • \$\begingroup\$ 10 bytes (or 8 with the -R flag). Sorry I haven't helped you golf your other solutions so far; I've been spending the time I normally spend golfing working on my new interpreter the past few days. I'll try to have a look at them tomorrow for you, though. \$\endgroup\$ – Shaggy Mar 6 at 23:14
  • \$\begingroup\$ @Shaggy Thanks, there are so many different functions in Japt, and the docs aren't always clear on what they do plus the fact I don't usually program in Javascript makes learning Japt pretty hard. Thank you for your aid! \$\endgroup\$ – Embodiment of Ignorance Mar 7 at 3:00
1
\$\begingroup\$

Perl 5, 32 30 bytes

map{say$_..Z,@b;push@b,$_}A..Z

Try it online!

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

Forth (gforth), 55 bytes

: f 26. do 26. do i j + 26 mod 65 + emit loop cr loop ;

Try it online!

Just for completeness. Tried several tricks (using one loop instead of 2, creating a string before printing) but they didn't save bytes. You can find such attempts in the TIO link above.

How it works

: f ( -- )
  26. do    \ A golfy way to loop from 0 to 25 inclusive
    26. do  \   Form a nested loop
      i j + 26 mod 65 +  \ Compute a char in range A..Z
      emit  \     Print that ASCII char
    loop    \   End inner loop
    cr      \   Print a newline
  loop ;    \ End outer loop
\$\endgroup\$
1
\$\begingroup\$

Poetic, 510 bytes

THE BOOGEYMAN WAS HERE,i read
a story i saw,a story i saw
it reads:WE SAW IN STARS AN END TO EARTH
i saw magic spells,oracles of chaos
i also saw hexes
o,i know a curse is a legend/a lie
i think i know a curse i saw
a curse is hogwash
now i browse a book
o,i laugh
it is trash
o,i giggle
in a bang,i heard a POW
a flash,a puff o flames
IT IS SATAN,said an unholy devil
go satan
i saw a story,i said,a story i saw
a coming doom,i said
a demon i saw
i scream:o,do beware of looming evils
o no

Try it online!

Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.

The point of the language is to allow for programs to be written in free-verse poetry. This specific poem was based on the brainfuck solution by Dorian (I had one, but it took longer to run and it was more bytes).

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

Python 2, 60 bytes

print''.join(chr(10+(-~i%27and 55+i%26))for i in range(701))

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

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

Racket, 130 bytes

(display(string-join(build-list 26((λ(l)(λ(n)(list->string(append(drop l n)(take l n)))))(map integer->char(range 65 91))))"
"))

Racket doesn't have a cycle-like function for its lists, so I have to make do.

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

C#, 100 bytes

Supplied because I think the other C# answer is invalid, and this is a different way of generating the table entirely. Full program because I don't like supplying just functions... and because it's 100bytes. Appears to use the same method as the VBA answer provided by Joffan.

class P{static void Main(){for(int i=0;i<702;i++)System.Console.Write((char)(i%27>25?10:i%26+65));}}

Optional trailing \n (change 702 to 701 to get rid of it). Very simple: works by counting from 0 to 26*27 (26 letters + 1 newline, 26 times). Each count of i, it prints the char value of either 10 (LF) if it is newline time (every 27th character), else it prints the capital ASCII numeral of the i%26th letter of the alphabet. The starting letter is implicitly offset by injecting the LF at every 27th character.

I am sad I can't move the i++ out of the loop declaration, but I don't think it pays to turn the conditional into a lookup/other, which would enable me to perform the increment after computing the alphabet ASCII value.

Formatted code:

class P
{
    static void Main()
    {
        for(int i=0;i<702;i++)
            System.Console.Write((char)(i%27>25?10:i%26+65));

        System.Console.ReadKey(true); // just for debug
    }
}
\$\endgroup\$
  • \$\begingroup\$ i++<702; instead of i<702;i++ for -1. Main(i){for(; instead of Main(){for(int i=0; for -10? \$\endgroup\$ – Erik the Outgolfer Jul 31 '16 at 16:15
  • \$\begingroup\$ @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ The first one isn't so simple, because we need to start at i=-1 instead, which just adds the byte back (we have to start a 0 because we are doing modulo). The second doesn't work, because C# doesn't guess types like C, and requires variables to be assigned before use (including primatives) \$\endgroup\$ – VisualMelon Jul 31 '16 at 16:18
  • \$\begingroup\$ Suffix incrementation does not return the incremented value, it returns the value before incrementation. If int i is equal to 16, i++ would return 16, not 17. \$\endgroup\$ – Erik the Outgolfer Jul 31 '16 at 16:21
  • \$\begingroup\$ @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ sorry, not sure I follow... it's i=0 so that the first value of i in the loop is 0 (so we get the alphabet proper, starting at 'A' - it's expensive to offset the modulus because it adds brackets). I am well acquainted with i++ and ++i, and note that they are well defined in C# (unlike C, I gather). I can't have the ++ in the i%27 because I need the same i in the i%26 (this will be the incremented value in C#, because it's to the right of the ++). This is why it would be nice to turn it around, and do a lookup on the value, so that the ++ can be at the end. \$\endgroup\$ – VisualMelon Jul 31 '16 at 16:26
  • \$\begingroup\$ At least you can surely save a byte using i++<702; instead of i<702;i++. Are you sure i++ returns incremented i instead of i? ( ) Yes ( ) No [Submit] \$\endgroup\$ – Erik the Outgolfer Jul 31 '16 at 16:40
0
\$\begingroup\$

ListSharp, 200 bytes

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

Even if you dont know this language, you can probably see how straight forward it is.

Thats the point of it, feel free to ask any questions

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

Python 2, 68 bytes

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

i=0;exec"print ''.join(chr(65+(i+j)%26)for j in range(26));i+=1;"*26
\$\endgroup\$
0
\$\begingroup\$

Java, 163 bytes

public class M{public static void main(String[]s){String a="abcdefghijklmnopqrstuvwxyz";for(int i=-1;++i<26;)System.out.println(a.substring(i)+a.substring(0,i));}}

More readable version:

public class M {
    public static void main(String[] s) {
        String a = "abcdefghijklmnopqrstuvwxyz";
        for (int i = -1; ++i < 26;)
            System.out.println(a.substring(i) + a.substring(0, i));
    }
}

Essentially, every iteration, it starts at index i and prints to the end, then starts at index 0 and prints to index i. I'm sure I could golf this down a bit.

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

Javascript (using external library) (88 bytes)

a=>_.Range(0,26).WriteLine(x=>_.Range(x,26).Write("",y=>String.fromCharCode((y%26)+65)))

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

Code explanation: Create range from 0 to 25. For each integer in range, write a line according to the predicate. For each integer, the predicate says to create a range starting at the current integer value, extending for 26 elements. That range is concatenated into a single string, according to a predicate that modulates that range's current integer value by 26, adds 65 because thats the code for 'A', then gets parsed to a string.

enter image description here

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

SAS/IML, 88 bytes

proc iml;a=j(26,26);do r=0to 25;a[r+1,]=mod((0:25)+r,26)+65;end;a=byte(a);print a;quit;

Explanation:

proc iml;        *necessary?;
  a=j(26,26);    *initialize matrix;
  do r=0to 25;   *iterate for 26;
      a[r+1,]=mod((0:25)+r,26)+65;  *Assign correct ASCII code - mod by 26;
  end;
  a=byte(a);     *use BYTE function, cannot use this on earlier line unfortunately;
  print a;       *actual output;
quit;            *necessary?;

Unfortunately have to initialize the matrix in IML for this to work, and cannot apply the byte() call in the assignment stage, so lose a few bytes there. Not sure if quit; should be needed, or even if proc iml; is needed, per rules - these are needed to type the whole thing into the SAS process as is, there is no IML specific executable, but there is "IML Studio" which perhaps would mean we don't need those 14 bytes?

Another SAS/IML option that golfs to a byte bigger - 89 bytes that is - is the equivalent of the R optimal solution:

proc iml;
  a=repeat('A':'Z',26);   *initialize array to all A-Z;
  do r=1 to 25;           *we have to (and want to) skip row one;
      a[r+1,]=a[1,r+1:26]||a[1,1:r];  *concatenate subvectors;
  end;
  print a;
quit;
\$\endgroup\$
  • \$\begingroup\$ I had hoped to do a bit better in the second solution by just squishing the whole vector again onto it, but that doesn't work because SAS won't automatically truncate the extra positions :( (Probably a good thing in real programming but a drag here!) \$\endgroup\$ – Joe Aug 1 '16 at 16:21
0
\$\begingroup\$

Groovy, 63

l='A'..'Z'as Queue;(l+[]).each{println l.join();l<<l.remove()}

Found a cool way to copy a list by using (l+[]) instead of l.clone()

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

awk, 89 86 85 59 chars

after @manatwork optimisation :

awk 'BEGIN{for(;n++<27;)for(c=64;++c<91;)printf"%c",++i%27?c:RS}'

--

before @manatwork optimisation: 85 chars (91 including awk invocation)

awk 'BEGIN{for(;n++<27;)for(c=64;++c<91;){if(++i%27){printf "%c",c}else{print;continue;}}}'

A little less efficient than @mattk answer, though... well done!

\$\endgroup\$
  • 1
    \$\begingroup\$ Too many braces around single instruction blocks. BEGIN{for(;n++<27;)for(c=65;c<91;c++)printf"%c",++i%27?c:RS}. \$\endgroup\$ – manatwork Aug 3 '16 at 13:20
  • \$\begingroup\$ @manatwork: ohh, very nice : i was wondering how to use "?:" for this, your usage is so much better than my (big) "if... else" \$\endgroup\$ – Olivier Dulac Aug 3 '16 at 13:23
  • 1
    \$\begingroup\$ As Dennis wrote, “This is a standalone awk program; you don't have to count the invocation.” \$\endgroup\$ – manatwork Aug 3 '16 at 13:37
  • \$\begingroup\$ @manatwork: thanks, it saves 6 more bytes ^^ (I'm (kind of) new to this...) \$\endgroup\$ – Olivier Dulac Aug 3 '16 at 13:39
0
\$\begingroup\$

Swift, 104 84 81 73 bytes

(0...701).map{print(UnicodeScalar($0%27==26 ?13:65+$0%26),terminator:"")}
\$\endgroup\$
0
\$\begingroup\$

Ruby, 43 bytes

26.times{|i|puts(([*?A..?Z]*2)[i,26].join)}

Explanation

[*?A..?Z]
This creates a list from 'A' to 'Z', using ruby's literal character syntax ?A and the splat operator on a range.

It then doubles this list, and cycles through it 26 times, printing out 26 characters with an increasing offset.

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

Mathematica, 56 bytes

StringRiffle[NestList[RotateLeft,Alphabet[],25],"\n",""]

Pretty simple. Just gets a list of all the rotations of the alphabet, then joins them with newlines and spaces within the lines.

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

Husk, 8 bytes

U¡ṙ1…"AZ

Try it online!

Explanation

     "AZ  -- string: "AZ"
    …     -- fill the gaps: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 ¡        -- iterate the following infinitely times & accumulate results in list
  ṙ1      -- rotate by 1 (eg. first time: "BCDEFGHIJKLMNOPQRSTUVWXYZA")
U         -- only keep the longest prefix with unique elements
\$\endgroup\$
0
\$\begingroup\$

Jelly, 7 bytes

ØAṙJṙ-Y

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