Kolmogorov shifter

37

1

Output or display the following three lines of text, exactly as they are shown below. A trailing newline is accepted.

 bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ

That block of text is the same as the one below, but where the n'th column is rotated n times downward:

 !"#$%&'()*+,-./0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz

Keep in mind that this is a challenge, so the output format is not flexible.

Stewie Griffin

Posted 2018-02-14T10:40:03.180

Reputation: 43 471

1Does the text end on a newline ? In particular is it ok to end on '....z\n\n` ? – Ton Hospel – 2018-02-14T18:03:26.300

2@Tom no, it should maximum be one trailing newline – Stewie Griffin – 2018-02-14T19:10:38.590

Is a leading newline acceptable? – Dom Hastings – 2018-02-15T08:42:08.517

@DomHastings No, sorry. – Stewie Griffin – 2018-02-15T08:43:51.440

(for many languages (HTML, ///, Text, Bubblegum) hardcoding those 80 characters would be (provably, except for Bubblegum) the shortest, that is boring, please don't do that) – user202729 – 2018-02-23T08:19:46.173

Answers

18

Java 8, 169 162 150 146 116 113 106 95 94 93 92 91 90 84 bytes

Yay, we finally did it! We've beat the 88-byte literal output that can be found at the bottom. Thanks to all those who participated in the golfing!

v->{for(int i=0,t=0;++i<81;System.out.printf("%c",i%27<1?10:(4-t++%3)*32%97+i%27));}

-7 bytes thanks to @StewieGriffin.
-42 bytes thanks to @Neil.
-11 bytes thanks to @PeterTaylor.
-3 bytes thanks to @OlivierGrégoire.
-6 bytes thanks to @OlivierGrégoire and @Neil (Olivier suggested a port of Neil's JavaScript answer).

Try it online.

Explanation:

v->{                          // Method with empty unused parameter and no return-type
  for(int i=0,t=0;++i<81;     //  Loop from 1 to 81 (exclusive)
     System.out.printf("%c",  //   Print the following character:
      i%27<1?                 //    If it's the last column
       10                     //     Print a new-line
      :                       //    Else:
       (4-t++%3)*32%97+i%27   //     Print the correct character based on the index

See here what each of the arithmetic parts do, and how it ends up at the correct characters.


Java 8, 88 bytes

v->" bC#eF&hI)kL,nO/qR2tU5wX8z\nA!cD$fG'iJ*lM-oP0rS3uV6xY9\naB\"dE%gH(jK+mN.pQ1sT4vW7yZ"

Boring, but utilizing the intended rotation of columns won't be any shorter in Java for sure.. I stand corrected! Will post a solution in a moment either way to see how much bytes it differs. Apparently the difference is just -4 bytes! :D

Try it online.


Kevin Cruijssen

Posted 2018-02-14T10:40:03.180

Reputation: 67 575

Would it be better to start with b="\n", c=b, and do return a+b+c;} in the end? TIO.

– Stewie Griffin – 2018-02-14T11:16:28.547

1Based on my CJam approach, I'm pretty sure there should be a reasonably simple arithmetic formula for the code point at position (x, y), which will most likely beat your 169-byte approach and maybe even the literal string. – Martin Ender – 2018-02-14T11:20:15.840

@MartinEnder I was currently working on something, which will probably beat the 162 bytes solution. I doubt anything beats the 88 byte solution in Java, though. – Kevin Cruijssen – 2018-02-14T11:21:28.940

Simple 150-byte solution: v->{String a[]=new String[]{"","\n","\n"};for(int i=31;++i<58;){a[-~i%3]+=(char)i;a[~-i%3]+=(char)(i+33);a[i%3]+=(char)(i+65);}return a[0]+a[1]+a[2];} – Neil – 2018-02-14T11:31:55.537

1116 bytes: v->{String a="";for(int i=2,j,t;++i<6;){for(j=31;++j<58;a+=(char)(t<1?j+65:t>1?j:j+33))t=(j-i)%3;a+="\n";}return a;} – Neil – 2018-02-14T12:15:14.573

@Neil Thanks, -42 bytes thanks to you. And I'm at 113 now by removing the brackets. – Kevin Cruijssen – 2018-02-14T12:29:40.347

Ah, of course, you can move the newline into the for clause. – Neil – 2018-02-14T12:38:01.087

The printf approach can be optimised by using a single loop. E.g. for 98: v->{for(int i=0,r,c;++i<81;System.out.printf("%c",c<1?10:32*(r=(i/27+28-c)%3+1)+c-(2>>r)))c=i%27;} – Peter Taylor – 2018-02-14T14:47:33.280

1Ahem, 95: v->{for(int i=0,r,c;++i<81;System.out.printf("%c",c<1?10:32*++r+c-1/r))r=(i/27+28-(c=i%27))%3;} – Peter Taylor – 2018-02-14T14:55:21.710

@PeterTaylor I knew it would be possible to change the two loops to a single loop, but couldn't really figure it out.. Thanks! Difference is just 7 bytes with hard-coded output now. :) – Kevin Cruijssen – 2018-02-14T15:15:29.117

For the breakdown it's more useful to split 32*++r+c-1/r as 32*++r-1/r and c. – Peter Taylor – 2018-02-14T16:10:35.170

192 bytes (removed c entirely) – Olivier Grégoire – 2018-02-15T11:07:30.463

191 bytes. I won't try to golf more. – Olivier Grégoire – 2018-02-15T13:29:29.300

1@OlivierGrégoire Thanks! And it can be 90 bytes with i/27-1-i as i/27+~i. :) – Kevin Cruijssen – 2018-02-15T13:31:00.623

1@KevinCruijssen Very likely: I rarely use that trick. ;-) But I have to admit I spent at least 20 minutes trying to golf more in that r=... assignment, and you did it in... 1 minute tops. – Olivier Grégoire – 2018-02-15T13:32:17.673

@OlivierGrégoire I use x+y+1 and x-y-1 with ~ pretty often in my answers, so I guess I just see those kind of golfs. What you did from 95 to 91 is far more impressive and I most likely wouldn't have been able to figure all that out myself even when I have a lot more time!

– Kevin Cruijssen – 2018-02-15T13:38:55.130

1

Well, I gotta eat my hat! 84 bytes (port of @Neil's Javascript answer)

– Olivier Grégoire – 2018-02-15T13:58:11.827

4@OlivierGrégoire Java outgolfing JavaScript? What did I do wrong? – Neil – 2018-02-15T19:55:33.380

13

Husk, 13 bytes

Tzṙṫ26¡m→"Aa 

Note the trailing space. Try it online!

Explanation

Tzṙṫ26¡m→"Aa   No input.
         "Aa   The string "Aa ".
      ¡        Iterate
       m→      map successor: ["Aa ","Bb!","Cc\"","Dd#",..
 z             Zip with
   ṫ26         the reversed range [26,25,24,..,1]
  ṙ            using rotation: [" Aa","b!B",..,"z9Z"]
               This also truncates the list to length 26.
T              Transpose, implicitly print separated by newlines.

Zgarb

Posted 2018-02-14T10:40:03.180

Reputation: 39 083

11

SPL (Shakespeare Programming Language), 1679 1618 1600 bytes

.
Ajax,.
Ford,.
Puck,.
Act I:.
Scene I:.
[Enter Ajax and Ford]
Ajax:
You are the remainder of the quotient between the sum of the remainder of the quotient between the product of me and a fat joy and the sum of the cube of a big red day and the difference between a red fat pig and a big old fat cow and the quotient between me and the sum of a day and the square of the sum of a joy and a big red day and the sum of a cat and a fat son.
[Exit Ajax]
[Enter Puck]
Ford:
Am I as good as nothing? If so, you are a bad big old red fat day. Am I as good as a joy? If so, you are the sum of a joy and a the cube of an old bad day. Am I as good as a big day? If so, you are the sum of the square of the sum of a big red fat cat and an old cow and the sum of an old war and a lie.
[Exit Ford]
[Enter Ajax]
Ajax:
You are the sum of thyself and the remainder of the quotient between me and the sum of a man and the square of the sum of a son and a big fat cow. Speak thy mind!
[Exit Puck]
[Enter Ford]
Ford:
You are the sum of yourself and a son.
Ajax:
You are the remainder of the quotient between me and the sum of a cat and the square of the sum of a cow and an old red sky.
Ford:
Am I as good as nothing? If so, let us proceed to scene III.
Scene II:.
Ajax:
You are the product of the sum of a fat man and a cow and the sum of a man and the square of the sum of a cat and a big red son. Are you not better than me? If so, let us return to act I. Let us proceed to scene IV.
Scene III:.
Ajax:
You are the sum of a big old fat cat and a red cow. Speak thy mind! Let us return to scene II.
Scene IV:.
[Exeunt]

I had some issues with the interpreter (https://github.com/drsam94/Spl), so it's not as small as I think it could have been. But at least this works :)


Here's the same logic in PHP, to make it a bit easier to see what's going on.

<?php

Act1Scene1:
$ford = ((2 * $ajax) % 52 + $ajax / 26) % 3;
if ($ford == 0) {
    $puck = 32;
}
if ($ford == 1) {
    $puck = 65;
}
if ($ford == 2) {
    $puck = 97;
}
$puck = $ajax % 26 + $puck;
echo chr($puck);

$ajax = $ajax + 1;

$ford = $ajax % 26;
if ($ford == 0) {
    goto Act1Scene3;
}

Act1Scene2:
if ($ajax < 78) {
    goto Act1Scene1;
}
goto Act1Scene4;

Act1Scene3:
$ford = 10;
echo chr($ford);
goto Act1Scene2;

Act1Scene4:

chocochaos

Posted 2018-02-14T10:40:03.180

Reputation: 547

4The speeches in this sound like a demented Dr. Seuss book. :^D – DLosc – 2018-02-15T18:25:25.543

10

JavaScript (ES6), 86 75 bytes

f=(i=k=0)=>i<80?String.fromCharCode(++i%27?(4-k++%3)*32%97+i%27:10)+f(i):''

Edit: Saved 11 bytes thanks to @Ryan. Now 10 bytes shorter than the literal!

JavaScript (Node.js), 64 bytes

f=(i=k=0)=>i<80?Buffer([++i%27?(4-k++%3)*32%97+i%27:10])+f(i):''

Try it online! Thanks to @Ryan.

Neil

Posted 2018-02-14T10:40:03.180

Reputation: 95 035

2You can save 11 bytes with recursion: f=(i=k=0)=>i-80?String.fromCharCode(++i%27?(4-k++%3)*32%97+i%27:10)+f(i):'' and 11 more in a Node environment as an aside: f=(i=k=0)=>i-80?Buffer([++i%27?(4-k++%3)*32%97+i%27:10])+f(i):'' – Ry- – 2018-02-17T10:45:45.190

8

05AB1E, 17 15 bytes

Saved 2 bytes thanks to Erik the Outgolfer

žQAuA)øε¼¾GÁ]ø»

Try it online!

Explanation

žQ                 # push the list of printable ascii characters
  Au               # push upper-case alphabet
    A              # push lower-case alphabet
     )ø            # zip
       ε           # apply to each
        ¼          # increment counter
         ¾G        # for N in [1 ... counter] do:
           Á       # rotate string right
            ]      # end loops
             ø     # zip
              »    # print list joined by newlines

Emigna

Posted 2018-02-14T10:40:03.180

Reputation: 50 798

@Emigna I feel like εN should be a thing. Combines the two ideas of vyNFÁ])ø» and yours. – Magic Octopus Urn – 2018-02-14T13:22:43.060

@MagicOctopusUrn: Yeah, I have often wanted N while using ε. It doesn't technically fit as ε isn't a loop, though as we sometimes use it as such, it would be nice to have it. – Emigna – 2018-02-14T13:34:16.673

8

CJam (18 bytes)

26{_" Aa"f+m>}%zN*

Online demo

Dissection

The obvious approach is to generate the original lines, zip, rotate with ee::m>, and zip back. But ee:: is quite long, and it's shorter to generate the columns directly.

26{         e# For i = 0 to 25...
  _" Aa"f+  e#   Generate the unrotated column by offsets from the starting chars
  m>        e#   Rotate the appropriate distance
}%
zN*         e# Zip and join the rows with newlines

Peter Taylor

Posted 2018-02-14T10:40:03.180

Reputation: 41 901

8

Python 2, 72 bytes

x=98
exec"r='';exec'r+=chr(x/3);x+=291*(x<180)-94;'*26;print r;x-=78;"*3

Try it online!

This works by removing 31.333.. from the previous character, adding 97 when the previous codepoint is less than 60, and subtracting 26 at the end of each line.

Rod

Posted 2018-02-14T10:40:03.180

Reputation: 17 588

8

R, 64 63 bytes

cat(intToUtf8(c(32:57,10,65:90,10,97:122,10)[(0:80*55)%%81+1]))

Try it online!

-1 byte thanks to Giuseppe

I arrived at this through quite a bit of trial and error, so I'm struggling with a concise explanation. Essentially, instead of the character codes, I started off with a more simple sequence of 1:81 representing the original block of text (3*26 plus 3 newlines), and examined the indices of where these values end up in the rotated block. This follows a regular sequence that drops by 26 each time, modulo 81 (or equivalently, increases by 55 mod 81). It was then a matter of recreating that sequence (0:80*55)%%81+1]), mapping to the real unicode values c(32:57,10,65:90,10,97:122,10), converting to characters and printing.

user2390246

Posted 2018-02-14T10:40:03.180

Reputation: 1 391

well done! I'll be bounty-ing this, although I really expected another solution in the 80+ byte range, so I think I'll up the bounty to 100. – Giuseppe – 2018-02-15T13:33:59.057

@Giuseppe No worries! It's more about the challenge than the rep to be honest. – user2390246 – 2018-02-15T14:05:34.500

ah, you can save a byte using 55 instead of -26 since -26 == 55 (mod 81). – Giuseppe – 2018-02-15T14:25:17.760

@Giuseppe Thanks for the suggestion, and for the bounty! – user2390246 – 2018-02-26T15:01:47.187

6

Japt, 17 15 bytes

"@`"
;By@=cÄ é

Test it online!

Explanation

"@`"         The string "@`\x1F". The following newline sets U to this string.
;            Reset variables A-L to various values. B is set to
 B           the uppercase alphabet, which we only use to get a length of 26.
  y@         Map each column Z (initially just the letter itself) through this function:
     cÄ        Increment each char-code in U.
        é      Rotate by 1 character.
    =          Set U to the result to keep the chain going.
             This generates the 26 columns exactly how we needed them.
             Implicit: output result of last expression

7 other possible 15-byters:

;By@" Aa"c+Y éY
;ByÈpv)iSc+Y)éY
;ByÈ+v)iSc+Y)éY
;ByÈpv)iYd32)éY
;ByÈ+v)iYd32)éY
;ByÈpv)i32dY)éY
;ByÈ+v)i32dY)éY

ETHproductions

Posted 2018-02-14T10:40:03.180

Reputation: 47 880

5

CJam, 23 21 bytes

3{26{_I-" aA"=+}/N}fI

Try it online!

Explanation

3{         e# For I from 0 to 2...
  26{      e#   For i 0 to 25...
    _I-    e#     Duplicate i and subtract I. This shifts the starting
           e#     character of each line left in the following string.
    " aA"= e#     Pick the character at the start of the unrotated line
           e#     of the current character. We basically just cycle
           e#     through non-letters, lower-case, upper-case, which is
           e#     the cycle throughout the result. Due to the I-, when
           e#     We get to the second line we start from A, and on the
           e#     third line we start from a.
    +      e#     Add i to the starting character to get the correct
           e#     column.
  }/
  N        e#   Push a linefeed.
}fI

Martin Ender

Posted 2018-02-14T10:40:03.180

Reputation: 184 808

3Very nice explanation. I especially like: "Push this random-looking string." :P – Stewie Griffin – 2018-02-14T11:07:36.680

2@StewieGriffin sorry, that string had to go. – Martin Ender – 2018-02-14T11:28:37.437

5

R, 88 86 bytes

cat(intToUtf8(rbind(diffinv(matrix(c(66,-32,-31),25,5,T)[,1:3],,,t(c(32,65,97))),10)))

Try it online!

R is terrible at string manipulation and although it has some neat matrix builtins, rotations are another thing it doesn't do very easily. I will happily give a bounty to anyone who can out-golf me in R.

Despite my having found a shorter answer, I'll still award a 50 rep bounty to the first other R answer shorter than 88 bytes.

I suppose I'd award myself the bounty if I could, but this is a whole two bytes shorter than the "boring" answer! I avoid rotations by just using R's penchant for recycling.

EDIT: user2390246's answer completely outgolfed me and I will be awarding a 100 point bounty since that solution is far superior.

To get here, I deconstructed the desired output to their ASCII code points with utf8ToInt (removing the newlines), built a matrix, and ran a diff on themm getting the columnwise differences. Noting the periodicity there, I set out to construct the matrix in a golfy fashion, hoping to use diffinv to recreate the original.

Thanks to the periodicity, we can recreate the diffed matrix by forcing R to recycle with a non-multiple length, and extract the columns we actually wanted:

matrix(c(66,-32,-31),25,5,T)[,1:3]

Then we invert this process, with diffinv to recreate the code points, append a row of 10 (newlines) to the bottom, reconvert to ASCII with intToUtf8, and cat the result.

Giuseppe

Posted 2018-02-14T10:40:03.180

Reputation: 21 077

3You can sort of give yourself a bounty. The bounty would cost you x rep, and you'd gain x rep from it... So, consider it done! – Stewie Griffin – 2018-02-14T15:21:34.563

2Challenge accepted! – user2390246 – 2018-02-15T13:13:51.570

5

MATL, 16 bytes

1Y2tk9V:v26:l&YS

Try it online!

Explanation

1Y2     % Push 'AB...Z' (predefined literal)
t       % Duplicate
k       % Maker lowercase
9V      % Push 9, convert to string representation: gives char '9'
:       % Range. For chars, gives string from space to that
v       % Concatenate vertically. Gives a 3×26 char matrix
26      % Push 26
:       % Range. For numbers, gives numeric vector from 1 to that
l&YS    % Circularly shift each column of the first input (char matrix)
        % by the amount specified by the second input (numeric vector).
        % Implicitly display

Luis Mendo

Posted 2018-02-14T10:40:03.180

Reputation: 87 464

2Nice :) I still struggle when I must change the default I/O formats of functions... :( – Stewie Griffin – 2018-02-14T12:41:47.817

1oohh very nice with the order of the strings to use 1:26 as the shift. I should try that in my R answer... – Giuseppe – 2018-02-14T13:42:01.373

1

@StewieGriffin Meta-function & was a great addition, from Suever's idea :-)

– Luis Mendo – 2018-02-14T14:58:04.560

@Giuseppe Yes, that saved a byte :-) – Luis Mendo – 2018-02-14T14:58:28.487

5

Perl 5, 46 bytes

print map{chr$n+++ord,$/x!($n%=26)}($",A,a)x26

Saved 13 bytes thanks to @TonHospel's arcane wizardry!

Try it online!

Dom Hastings

Posted 2018-02-14T10:40:03.180

Reputation: 16 415

Your $i++ is just $_ and you can use say instead of print so this is really 50 – Ton Hospel – 2018-02-14T14:26:56.150

Mmm, and it's easy to get rid of the {} in the map too for 49: say map$/x/26|52/.chr$_%26+(32,65,97)[$_%3],0..77 – Ton Hospel – 2018-02-14T14:57:24.167

@TonHospel Yes, of course! Thanks! – Dom Hastings – 2018-02-14T15:37:09.957

Redesigning the loop gives 47: print map{chr$n+++$_,$/x!($n%=26)}(32,97,65)x26. Unfortunately say gives one newline too many. – Ton Hospel – 2018-02-14T18:20:04.170

And a fun 48: say map$/x/.A/.chr$n++%26+(65,32,97)[$n%3],A..BZ – Ton Hospel – 2018-02-14T19:32:18.773

@TonHospel ah that's clever. Thank you! I prefer the non-say approaches for general questions too! – Dom Hastings – 2018-02-14T21:16:51.533

And 46: print map{chr$n+++ord,$/x!($n%=26)}($",A,a)x26 – Ton Hospel – 2018-02-14T22:39:48.033

@TonHospel Thank you! That's also really clever, it's making me think about printfs viability too... I'll continue to play with it! – Dom Hastings – 2018-02-15T08:32:04.380

5

Stax, 14 12 bytes

ü≤▐éh╢%╠£┐3]

Run and debug it

Unpacked, ungolfed, and commented, it looks like this.

3R26        push [1,2,3] and 26
K           cross-map using the rest of the program, printing lines implicitly
            this instruction maps over a cartesian join
  -         subtract
  " Aa"@    index into " Aa" using the subtraction result
  i+        add the iteration index

Run this one

This program only uses features that have been available since the initial release of stax, but apparently I forgot about K for cross-map when I originally write this answer.

One nearly interesting thing to note about this answer is that the R is an unnecessary instruction because K implicitly turns integers into ranges. However there's no way to push 3 and 26 without some extra byte in between.

recursive

Posted 2018-02-14T10:40:03.180

Reputation: 8 616

5

Jelly, 13 bytes

26“ aA‘ẋs+ḶỌY

Try it online!

How it works

26“ aA‘ẋs+ḶỌY  Main link. No arguments.

26             Set the argument and the return value to 26.
  “ aA‘ẋ       Repeat [32, 97, 65] (code points of ' ', 'a', and 'A') 26 times.
        s      Split the result into chunks of length 26.
          Ḷ    Unlength; yield [0, ..., 25].
         +     Add [0, ..., 25] to each of the chunks.
           Ọ   Unordinal; cast all integers to characters.
            Y  Jojn, separating by linefeeds.

Dennis

Posted 2018-02-14T10:40:03.180

Reputation: 196 637

4

Charcoal, 26 21 15 bytes

E³⭆⧧⟦γαβ⟧⁻κμμ

Try it online! Link is to verbose version of code. Explanation:

 ³              Literal 3
E               Map over implicit range
   β            Lowercase letters
  ⭆             Map over characters and concatenate
            κ   Outer index
             μ  Inner index
           ⁻    Subtract
       γ        Printable characters
        α       Uppercase letters
         β      Lowercase letters
     §⟦   ⟧     Circularly index into list (selects one of the three strings)
              μ Inner index
    §           (Circularly) index into string
                Implicitly print each inner map result on a separate line

Neil

Posted 2018-02-14T10:40:03.180

Reputation: 95 035

4

J, 29, 27 25 bytes

-2 bytes thanks to FrownyFrog -2 bytes thanks to miles

 |:u:(<26)2&(|.>:)32 65 97

Try it online!

Initial approach: J, 29 bytes

u:(-|."_1&.|:32 65 97+/])i.26

Explanation: i.26 - range 0-26

   i.26
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

32 65 97+/] - create a 3-row table for the characters

   32 65 97+/i.26
32 33 34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57
65 66 67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

&.|: transpose then do the next verb (|.) and transpose again

-|."_1 rotate each row n times

     (-i.26)|."_1|:32 65 97+/i.26
 32  65  97
 98  33  66
 67  99  34
 35  68 100
101  36  69
 70 102  37
 38  71 103
104  39  72
 73 105  40
 41  74 106
107  42  75
 76 108  43
 44  77 109
110  45  78
 79 111  46
 47  80 112
113  48  81
 82 114  49
 50  83 115
116  51  84
 85 117  52
 53  86 118
119  54  87
 88 120  55
 56  89 121
122  57  90

u: convert to unicode

    u:(-i.26)|."_1&.|:32 65 97+/i.26
 bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ

Try it online!

Galen Ivanov

Posted 2018-02-14T10:40:03.180

Reputation: 13 815

@FrownyFrog Thank you! Apparently I didn't check the possibility to create the matrix column-wise. – Galen Ivanov – 2018-02-14T19:16:17.170

2|:u:(<26)2&(|.>:)32 65 97 saves 2 bytes. – miles – 2018-02-14T23:54:13.290

@miles Thanks for the great code! – Galen Ivanov – 2018-02-15T00:05:41.033

4

PowerShell, 53 bytes

0..2|%{-join(32..57|%{[char]($_+(0,65,33)[$j++%3])})}

Try it online!

I see this is similar to Dom's Perl answer, but I arrived at it independently.

This exploits the fact that the pattern goes Symbol - Lowercase - Capital, even when wrapping newlines (8 - z - A, for example), and thus just adds the appropriate offset (chosen via $j++%3) to the current number $_ before -joining those together into a single string. That's done three times to come up with the three lines (preserving $j between iterations). Those three lines are left on the pipeline, and the implicit Write-Output gives us the newlines for free.

AdmBorkBork

Posted 2018-02-14T10:40:03.180

Reputation: 41 581

4

Julia 0.6, 79 bytes

println.([prod([' ':'9' 'A':'Z' 'a':'z'][n,mod1(i-n,3)] for n=1:26) for i=2:4])

[' ':'9' 'A':'Z' 'a':'z'] is the unrotated 2d array of characters, [n,mod1(i-n,3)] indexes into that array with appropriate rotation. prod takes a Vector of Characters to a String (since multiplication is used for string join). There are two nested Vector comprehensions resulting in a Vector containing 3 strings, then println. prints the each string in the Vector followed by a newline.

TIO lacks the appropriate method to multiply (with prod) two characters to get a String. I know that method was added somewhat recently, but the TIO version appears to be the same as the version on my PC where this code works, so I can't fully explain why it doesn't work on TIO.

Copy paste example (the ; isn't necessary, it just supresses extra output in the REPL):

julia> println.([prod([' ':'9' 'A':'Z' 'a':'z'][n,mod1(i-n,3)] for n=1:26) for i=2:4]);
 bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ

gggg

Posted 2018-02-14T10:40:03.180

Reputation: 1 715

4

C, 70 69 67 60 64 bytes

i;f(t){for(i=t=0;++i<81;putchar(i%27?(4-t++%3)*32%97+i%27:10));}

+4 bytes to make the function reusable.

Invalid 60-bytes answer that isn't reusable:

i,t;f(){for(;++i<81;putchar(i%27?(4-t++%3)*32%97+i%27:10));}

Port of my Java 8 answer @Neil's JavaScript answer.

Try it online.

Kevin Cruijssen

Posted 2018-02-14T10:40:03.180

Reputation: 67 575

Since functions have to be reusable and this function does not exit cleanly, it leaves the global variables behind. You need an i=t=0. – Jonathan Frech – 2018-02-28T01:07:11.780

@JonathanFrech Fixed – Kevin Cruijssen – 2018-02-28T07:47:21.433

3

Vim, 81 79 bytes

a !"#$%&'()*+,-./0123456789␛:h<_␍jjYZZpPgU$klqq"aDjlma"bD"ap`ajD"bpkkp`akl@qq@q

Explanation (simplified)

a !"#$%&'()*+,-./0123456789␛    Insert the first line
:h<_␍jjYZZpPgU$                  Insert the alphabet twice by copying it from the help page
klqq                             Define the loop `q`:
"aDjl                             Cut the rest of the line to `a`
ma"bD"ap                          Replace the rest of the second line (cut `b`, paste `a`)
`ajD"bp                           Replace the rest of the third line (cut `c`, paste `b`)
kkp                               Paste `c`
`akl@qq@q                        Run the loop, each time one more step to the right

Herman L

Posted 2018-02-14T10:40:03.180

Reputation: 3 611

3

APL+WIN, 26 bytes

Index origin 0

⎕av[(-⍳26)⊖32 65 97∘.+⍳26]

Generate a matrix of integer index values of the characters in the APL atomic vector.

Rotate each column downwards by its number value.

Use the resulting indices to display the characters from the atomic vector.

Graham

Posted 2018-02-14T10:40:03.180

Reputation: 3 184

3

Japt, 17 bytes

26Æ" Aa"c+X éX÷y

Test it


Explanation

26Æ           Ã       :Create the range [0,26) and pass each X through a function
   " Aa"              :  String literal
        c+X           :  Add X to the codepoint of each character
            éX        :  Rotate right X times
               ·      :Join with newlines
                y     :Transpose

Shaggy

Posted 2018-02-14T10:40:03.180

Reputation: 24 623

Oooh, I had a different solution that may or may not be enough to warrant a separate answer: ;Bå_cÄ é}"@`" ·y

– ETHproductions – 2018-02-14T13:07:10.337

Well now that we're the same length I feel better about it ;-) – ETHproductions – 2018-02-14T13:13:17.847

@ETHproductions: looks different enough to me :) Was going to see if I could come up with a shorter solution by mapping over C after lunch. Don't know how y and · ended up the wrong way 'round; I must have Ctrl+Zed too many times before Ctrl+Aing! – Shaggy – 2018-02-14T13:18:42.307

3

C, 72 bytes

f(k,x,n){for(n=81;n;putchar(x?k*32+59-x-!k:10))x=--n%27,k=(3+x-n/27)%3;}

anatolyg

Posted 2018-02-14T10:40:03.180

Reputation: 10 719

3

Python 2, 65 bytes

for x in 2,99,196:s='';exec"s+=chr(32+x%291/3);x-=94;"*26;print s

Try it online!

xnor

Posted 2018-02-14T10:40:03.180

Reputation: 115 687

3

brainfuck, 121 115 bytes

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

Thanks to @JoKing for saving 6 bytes!

Try it online!

Dennis

Posted 2018-02-14T10:40:03.180

Reputation: 196 637

115 bytes by fiddling about with the number generation – Jo King – 2018-02-21T01:24:05.380

2+++[[<+>>++<-]>] really is the start of everything, huh? Thanks! – Dennis – 2018-02-21T01:38:45.857

2

Jelly, 16 bytes

“ Aa‘ṙ2‘$25СỌZY

Try it online!

-4 thanks to miles.

Erik the Outgolfer

Posted 2018-02-14T10:40:03.180

Reputation: 38 134

19 bytes – dylnan – 2018-02-14T16:55:56.660

(I used LÐṀ instead of ḣ26 but there was no reason as it didn't save any bytes) – dylnan – 2018-02-14T16:57:03.853

@dylnan thanks, I'll update later – Erik the Outgolfer – 2018-02-14T16:57:44.183

18 bytes – dylnan – 2018-02-14T17:09:36.947

17 bytes sorry for the barrage – dylnan – 2018-02-14T17:14:49.350

@dylnan oh don't worry, I appreciate your input – Erik the Outgolfer – 2018-02-14T17:17:33.687

16 bytes “ Aa‘ṙ2‘$25СỌZY using the same method from my J comment. – miles – 2018-02-15T02:10:49.483

@miles ...or “ Aa‘ṙ-‘$25СỌZY, but thanks! – Erik the Outgolfer – 2018-02-15T10:47:53.973

2

Python 2, 79 bytes

p=0
exec"o=0;r='';exec'r+=chr(o+[32,65,97][(p-o)%3]);o+=1;'*26;p+=1;print r;"*3

Try it online!

ovs

Posted 2018-02-14T10:40:03.180

Reputation: 21 408

2

APL (Dyalog Unicode), 23 bytes (Adám's SBCS)

(⎕UCS-⊖∘↑32 65 97+⊂)⍳26

Try it online!

-1 thanks to Adám.

Runs in an interactive environment.

Assumes ⎕IO←0.

Erik the Outgolfer

Posted 2018-02-14T10:40:03.180

Reputation: 38 134

23: (⎕UCS-⊖∘↑32 65 97+⊂)⍳26 or (⎕UCS-⊖32 65 97∘.+⊢)⍳26

– Adám – 2018-02-14T12:15:58.330

@Adám Uh, thanks. – Erik the Outgolfer – 2018-02-14T12:18:33.853

2

Perl, 49 46 bytes

perl -E 'say map chr($_*55%81)=~y// -:A-Z             
a-z       
/cr,0..79'

or

perl -E 'say grep{$_=chr$_*55%81;y// -:A-Z             
a-z       
/c}0..79'

Ton Hospel

Posted 2018-02-14T10:40:03.180

Reputation: 14 114

+1! I can't help you save any bytes back, but I wondered about using $^x8, but can't think of another var with enough length, perhaps "@INC" but it's too long, and using "@-" instead of $n++, but still, same length. Unless that helps you shrink this further? Unless you add -p flag and have implicit output? – Dom Hastings – 2018-02-14T15:39:14.980

1@DomHastings Ah, found a way to loop without needing so much preparation – Ton Hospel – 2018-02-14T22:27:19.403

2

Ruby, 71 63 bytes

3.times{|j|26.times{|i|$><<(i+"aA aA "[2-j+i%3].ord).chr}
puts}

Try it online!

For a bit there I was worried I wouldn't be able to beat the string literal version.

-8 bytes: Index into a 6-character string, instead of a rotating 3-int array

3.times{|j|
  26.times{|i|
    # Find the appropriate base character (2-j+i%3)
    # Add i to the ascii value of that character
    # Push to STDOUT
    $><< (i + "aA aA "[2 - j + i % 3].ord).chr
  }
  # newline
  puts
}

benj2240

Posted 2018-02-14T10:40:03.180

Reputation: 801

2

SOGL V0.12, 15 bytes

 9ΔZz⁰I{∑ē⌡«}⁰H

Try it Here!

Explanation:

 9               push "9"
  Δ              range from " " to "9" (that 1st space has nothing to do with this)
   Zz            push the uppercase and lowercase alphabets
     ⁰           wrap those in an array
      I          and rotate clockwise
       {    }    for each item
        ∑          join the item together
         ē⌡        counter times
           «         rotate the string left
             ⁰   wrap that all in an array
              H  and rotate anti-clockwise

dzaima

Posted 2018-02-14T10:40:03.180

Reputation: 19 048

2

K4, 38 bytes

Solution:

-1"c"$+(-t).q.rotate'32 65 97+/:t:!26;

Example:

q)k)-1"c"$+(-t).q.rotate'32 65 97+/:t:!26;
 bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ

Explanation:

9 characters to perform the rotation...

-1"c"$+(-t).q.rotate'32 65 97+/:t:!26;
-1                                   ; / print to stdout, swallow return
                                  !26  / til 26, 0..25
                                t:     / save as variable t
                             +/:       / add each right item to...
                     32 65 97          / the list 32, 65, 97 (ASCII offsets)
           .q.rotate'                  / rotate each-both
       (-t)                            / negate, 0..-25
      +                                / flip rows and columns
  "c"$                                 / cast to characters

streetster

Posted 2018-02-14T10:40:03.180

Reputation: 3 635

2

Perl 6,  76 57  55 bytes

$/=|120.comb;.put for [Z~] map *.[|$/.=rotate(-1)],[Z] ' '..~9,'A'..*,'a'..*

Try it

.put for [Z~] ((' Aa','a A','Aa ')».ords «+»^26)».chr

Try it

.put for [Z~] (<!Bb b!B Bb!>».ords «+»(^26-1))».chr

Try it

Explanation

( ' Aa', 'a A', 'Aa ' )».ords

  ( (32, 65, 97),    # ' Aa'.ords
    (97, 32, 65),    # 'a A'.ords
    (65, 97, 32), )  # 'Aa '.ords

(^26 is short for 0..^26 which is similar to 0..26-1)

… «+» ^26            # matrix add; extending both sides

  #   + line 1
  #   |    + line 2
  #   |    |    + line 3           +-------------+-------------+ repeat 0..25
  #   V    V    V                  V             V             V
  ( ( 32,  65,  97), # ( (.[0;0] + 0), (.[0;1] + 0), (.[0;2] + 0) ),# <+ repeat
    ( 98,  33,  66), # ( (.[1;0] + 1), (.[1;1] + 1), (.[1;2] + 1) ),#  | ' Aa'.ords
    ( 67,  99,  34), # ( (.[2;0] + 2), (.[2;1] + 2), (.[2;2] + 2) ),#  |
                                                                    #  |
    ( 35,  68, 100), # ( (.[0;0] + 3), (.[0;1] + 3), (.[0;2] + 3) ),# <+
    (101,  36,  69), # ( (.[1;0] + 4), (.[1;1] + 4), (.[1;2] + 4) ),#  |
    ( 70, 102,  37), # ( (.[2;0] + 5), (.[2;1] + 5), (.[2;2] + 5) ),#  |
                                                                    #  |
    ( 38,  71, 103), # ( (.[0;0] + 6), (.[0;1] + 6), (.[0;2] + 6) ),# <+
    (104,  39,  72), # ( (.[1;0] + 7), (.[1;1] + 7), (.[1;2] + 7) ),
    ( 73, 105,  40), # ( (.[2;0] + 8), (.[2;1] + 8), (.[2;2] + 8) ),
    … )
(…)».chr             # (…).deepmap(*.chr)

  #   + line 1
  #   |    + line 2
  #   |    |    + line 3
  #   V    V    V
  ( (' ', 'A', 'a'),
    ('b', '!', 'B'),
    ('C', 'c', '"'),
    ('#', 'D', 'd'),
    ('e', '$', 'E'),
    ('F', 'f', '%'),
    … )
[Z~] …               # reduce using zip meta-op combined with concat op
                     # (has effect of rotating 90°, and joining)

  ( ' bC#eF&hI)kL,nO/qR2tU5wX8z',
    "A!cD$fG'iJ*lM-oP0rS3uV6xY9",
    'aB"dE%gH(jK+mN.pQ1sT4vW7yZ', )
.put for …           # loop over them printing them with trailing newline

Brad Gilbert b2gills

Posted 2018-02-14T10:40:03.180

Reputation: 12 713

2

Ruby, 59 bytes

Try it online!

a=%w[\  A a]
75.times{|i|a[i%3]<<a[~-i%3][i/3].next}
puts a

Initiates an array with first characters of the three strings and then grows them in a single loop.

Kirill L.

Posted 2018-02-14T10:40:03.180

Reputation: 6 693

The one-loop approach is very clever. – benj2240 – 2018-02-23T17:05:00.313

2

C (gcc) 59 58 55 bytes

t;f(i){for(;putchar(i++%27?t%26+" aA"[t++%3]:10)^90;);}

Reusable millions of times, until t oveflows

PrincePolka

Posted 2018-02-14T10:40:03.180

Reputation: 653

1

JavaScript (ES6), 85 bytes

_=>` bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ`

f=_=>` bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ`
o.innerText=f()
<pre id=o>

Herman L

Posted 2018-02-14T10:40:03.180

Reputation: 3 611

1

C (gcc), 108 bytes

f(j,k){for(k=0;k<3;k++){for(j=0;j<26;)putchar(j+!(j%3-k)*32+!(-~-~k%3-j%3)*65+!(-~k%3-j++%3)*97);puts("");}}

Try it online!

Jonathan Frech

Posted 2018-02-14T10:40:03.180

Reputation: 6 681

1

Pip, 24 bytes

Requires -l flag.

Z:B@{-a+^012}ME Z[PAAZz]

Try it online!

Explanation

Z:B@{-a+^012}ME Z[PAAZz]
                          PA is string of all printable ASCII characters; AZ is uppercase
                          letters; z is lowercase letters (implicit)
                 [PAAZz]  Construct a list of those three strings
                Z         Zip (transpose), clipping PA to the length of the shorter two
             ME           Map-enumerate: apply the following function to the index (a) and
                          value (b) of each item in the list:
        ^012               Split 012 into a list of digits [0 1 2]
     -a+                   To each, add negative a
    {       }              Modify that function
  B@                       by using its return value to index into b
Z:                        Take the result of the map operation and zip it again
                          Print, each sublist concatenated on a separate line (-l flag)

DLosc

Posted 2018-02-14T10:40:03.180

Reputation: 21 213

1

><>, 57 bytes

0 >::dd+%$3%3$-3%1+v
;v^?%+dd:+1o+,2*'A'<
> ^
?a
%o
3:
^<

Try it online!

recursive

Posted 2018-02-14T10:40:03.180

Reputation: 8 616

245 bytes. Remember that newlines cost bytes too! – Jo King – 2018-02-23T10:41:34.887

1

Python 3, 71 bytes

print(''.join(chr(b%3*65%97+b%26+32)+'\n'[25-b%26:]for b in range(78)))

Try it online!

RootTwo

Posted 2018-02-14T10:40:03.180

Reputation: 1 749

1

Yabasic, 88 bytes

An anonymous solution that takes no input and outputs to the console in text-graphics mode.

Note: the standard Yabasic host will place the message ---Program done, press RETURN--- over top the second line of output so a terminal line such as ?:? must be added to the end of the solution to push this message down by two or more lines.

Clear Screen
For c=0To 25
For r=0To 2
?@(c,Mod(r+c,3))Chr$(c-.5*r^2+33.5*r+32)
Next
Next

Output

enter image description here

Literal Solution, 86 bytes

?" bC#eF&hI)kL,nO/qR2tU5wX8z\nA!cD$fG'iJ*lM-oP0rS3uV6xY9\naB\"dE%gH(jK+mN.pQ1sT4vW7yZ"

Try it online!

Taylor Scott

Posted 2018-02-14T10:40:03.180

Reputation: 6 709

1

><>, 38 bytes

>ldd+%3l3%-'A'*2,+ol0ld6*)?;ldd+%.
/ao

Try it online!

Jo King

Posted 2018-02-14T10:40:03.180

Reputation: 38 234

0

PHP, 74 bytes

for(;$a<78;$a++)echo$a%26?'':'
',chr($a%26+[32,65,97][(2*$a%52+$a/26)%3]);

chocochaos

Posted 2018-02-14T10:40:03.180

Reputation: 547