g | x | w | all
Bytes Lang Time Link
122JavaScript Node.js250721T192656ZFhuvi
096JavaScript Node.js250722T074329Zrougepie
036Uiua250718T123524Znyxbird
021Vyxal 3250716T190528Zpacman25
062PowerShell 6+200916T145753Zmazzy
027Japt R200831T143720ZShaggy
02405AB1E200831T123909ZKevin Cr
026Brachylog200829T003540ZUnrelate
023Jelly200828T094850ZUnrelate
064x8616 machine code200828T164921Z640KB
071Kotlin200828T154130Zuser
040Jelly161003T190745ZErik the
151///161003T180750ZErik the
080Haskell161003T190810ZAngs
131Prolog120312T124940Zmarinus
062Ruby120115T174852ZHauleth
063Q120309T005148Ztmartin
063Q120309T142329Zskeevey
045J120115T131355ZGareth
043APL120116T011408ZDillon C
099Smalltalk120115T185913ZHauleth
098C111203T161610Zhan
070Scala111208T071035Zuser unk
073Python111205T203554ZSteven R
083JavaScript111205T185130ZIlmari K
073Groovy111205T171920ZArmand
073Mathematica111203T045424ZMr.Wizar
063Perl111202T121346ZIlmari K
124D111202T120731Zratchet
073Perl111202T094246ZToto
075R111202T102131ZAndrie
094Haskell111202T045243Zhammar
103Javascript111202T043911Zstephenc

JavaScript (Node.js), 122 125 bytes

-3 bytes with some refactoring.
Still, j>34?(...):[33,63,44,46][j-31] costs a lot to obtain the ASCII codes for "!?,.".
I wonder if it's possible to obtain them with a single shorter calculation.

I tried to do an ASCII codes approach to avoid having the hard-coded 40 bytes string and the for and substr, but somehow ended up with around 40 more bytes than the currently shortest JS answer :'(

console.log(""+Buffer(151).map((c,i)=>++i%4?[(j=i-(i>>2)*3)%10+48,85-j,j+54,j>34?125-j:[33,63,44,46][j-31]][--j/10|0]:10))

Try it online!


Here's the explanation in case of need of further debugging:

""+Buffer(151).map(...) handles the conversion of ASCII codes to string, and a loop over the 151 needed characters (including newlines)

i%4 is used to transform every fourth character into a newline (ASCII code 10 at the end)

The variable j=i-(i>>2)*3 is used to transform the 1-based-index 123456... into the corresponding wanted value 123234... (ignoring line breaks for the example)

We initialize an array with:

[ first_quarter_computing  = (j)%10+48
  second_quarter_computing = 85-j
  third_quarter_computing  = j+54
  fourth_quarter_computing = 125-j or the codes 33,63,44,46 for "!?,." ]

We use --j/10|0 to access the needed "quarter computing"

JavaScript (Node.js), 96 bytes

Pretty decent solution, IMO, but it can hardly beat the one from Ilmari Karonen

[...'1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'].map((e,i,a)=>i<38&&console.log(e+a[i+1]+a[i+2]))

Try it online!


The explanation is simple:

Uiua, 36 bytes

⧈⊟₃♭⍥⇌◿2°⊏↯4_∞⊂+@0↻1⇡10⊂+@A⇡26".,?!"

Try it!
this feels too long. hm.

⧈⊟₃♭⍥⇌◿2°⊏↯4_∞⊂+@0↻1⇡10⊂+@A⇡26".,?!"
                                 ".,?!" # punctuation
                          ⊂+@A⇡26       # add alphabet
                ⊂+@0↻1⇡10              # add numbers
            ↯4_∞                        # turn into 4x10
    ⍥⇌◿2°⊏                             # flip every other row
⧈⊟₃♭                                    # flatten and take windows

Vyxal 3, 21 bytes

kd↺m".,?!"W“4÷UVI“3o”

Vyxal It Online!

PowerShell 6+, 62 bytes

0..37|%{'1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'|% s*g $_ 3}

Try it online!

where s*g is the shorcut for the Substring method.

Japt -R, 27 bytes

;9õ pUB".,?!" ¬ò10 ËzEÑìã3

Test it

;9õ pUB".,?!" ¬ò10 ËzEÑìã3
 9õ                             :Range [1,9]
    p                           :Push
     U                          :  0
;     B                         :  Uppercase alphabet
       ".,?!"                   :  String literal
              ¬                 :Join
               ò10              :Partitions of length 10
                   Ë            :Map each string a 0-based index E
                    z           :  Rotate clockwise 90 degrees
                     EÑ         :  E*2 times
                       Ã        :End map
                        ¬       :Join
                         ã3     :Substrings of length 3
                                :Implicit output, joined with newlines

05AB1E, 24 bytes

žhÀAu".,?!"«Tô2Å€R}J«ü3»

Try it online.

Minor alternative:

Au".,?!"«TôžhÀšεNFR]Jü3»

Try it online.

Explanation:

žh                       # Push builtin "0123456789"
  À                      # Rotate it once to the left: "1234567890"
   Au                    # Push the uppercase alphabet
     ".,?!"«             # Append ".,?!" to it
            Tô           # Split it into parts of size 10:
                         #  ["ABCDEFGHIJ","KLMNOPQRST","UVWXYZ.,?!"]
              2Å€ }      # For every 2nd item (0-based index modulo 2 == 0):
                 R       #  Reverse it
                         #   ["JIHGFEDCBA","KLMNOPQRST","!?,.ZYXWVU"]
                   J     # Join the list together to a single string again:
                         #  "JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"
                    «    # Merge it to the digits:
                         #  "1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"
                     ü3  # Create overlapping triplets
                       » # Join the list by newlines
                         # (after which it is output implicitly with trailing newline)

Au".,?!"«Tô              # Same as above: ["ABCDEFGHIJ","KLMNOPQRST","UVWXYZ.,?!"]
           žhÀ           # Same as above: "1234567890"
              š          # Prepend it to the list:
                         #  ["1234567890","ABCDEFGHIJ","KLMNOPQRST","UVWXYZ.,?!"]
               ε         # Map each string to:
                NF       #  Loop the 0-based map-index amount of times:
                  R      #   Reverse the string every iteration
                   ]     # Close both the loop and map
                    J    # Join the list together to a single string again:
                         #  "1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"
                     ü3» # Same as above
                         # (after which it is output implicitly with trailing newline)

Brachylog, 26 bytes

Ị↺,Ạ,".,?!"ụḍ₄{i↔ⁱ⁾}ᶠcs₃ẉ⊥

Try it online!

Essentially a translation of my Jelly answer. A full program which prints the desired output with a trailing newline.

Ị                             "0123456789"
 ↺                            rotated once to the left
  ,                           concatenated with
   Ạ                          the alphabet (lowercase)
    ,".,?!"                   concatenated with ".,?!",
           ụ                  uppercased,
            ḍ₄                sliced into quarters.
                     c        Concatenate
              {    }ᶠ         every possible result from
               i              taking a slice with its 0-index
                ↔             and reversing it
                 ⁱ⁾           a number of times equal to the index.
                        ẉ     Print with a newline
                      s₃      a substring of length 3 from the concatenation,
                         ⊥    then try again with a different substring.

If a trailing newline is unacceptable:

Brachylog, 27 bytes

Ị↺,Ạ,".,?!"ụḍ₄{i↔ⁱ⁾}ᶠcs₃ᶠ~ṇ

Try it online!

Outputs as a function.

Jelly, 24 23 bytes

ØDṙ1;ØA;“.,?!”s⁵UÐeFṡ3Y

Try it online!

Generates the keyboard top to bottom left to right, then boustrophedonizes it afterwards.

ØD                         "0123456789"
  ṙ1                       rotated once to the left
    ;                      concatenated with
     ØA                    the uppercase alphabet
       ;“.,?!”             concatenated with ".,?!".
              s            Chop it into slices of length
               ⁵           10,
                U          (vectorized) reverse
                 Ðe        the slices at even 1-indices,
                   F       smash the slices back together,
                    ṡ3     take every contiguous sublist of length 3,
                      Y    and join on newlines.

x86-16 machine code, PC DOS, 64 bytes

Binary:

00000000: b409 bb1b 01ba 1801 bf0a 24b1 2687 3fcd  ..........$.&.?.
00000010: 2187 3f42 43e2 f6c3 3132 3334 3536 3738  !.?BC...12345678
00000020: 3930 4a49 4847 4645 4443 4241 4b4c 4d4e  90JIHGFEDCBAKLMN
00000030: 4f50 5152 5354 213f 2c2e 5a59 5857 5655  OPQRST!?,.ZYXWVU

Listing:

BB 011B     MOV  BX, OFFSET KB+3        ; pointer to end of 3 char substring 
BA 0118     MOV  DX, OFFSET KB          ; pointer to beginning of 3 char substring 
BF 240A     MOV  DI, 240AH              ; string '$' + 0AH 
B1 26       MOV  CL, 38                 ; number of lines 
B4 09       MOV  AH, 9                  ; DOS API output string function     
        CLOOP: 
87 3F       XCHG DI, WORD PTR[BX]       ; swap string term and LF char after 3 chars 
CD 21       INT  21H                    ; write substring to console 
87 3F       XCHG DI, WORD PTR[BX]       ; swap back 
42          INC  DX                     ; increment string start pointer 
43          INC  BX                     ; increment string end pointer 
E2 F6       LOOP CLOOP                  ; loop until 38 lines 
C3          RET                         ; return to DOS
        KB: 
            DB  '1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'

It's a bit of a naïve approach, but still fits well below the spec size (and is a nice power of 2). Loops through the string and swaps the relative 4th and 5th character with a LF followed by a string terminator and then outputs it.

Standalone DOS executable COM program. Output:

Head:

enter image description here

Tail:

enter image description here

Kotlin, 140 71 bytes

"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU".windowed(3).map{println(it)}

Try it online!

I just realized it's easier to use the string itself instead of generating it using ranges.

Jelly, 41 40 bytes

ØAḣ⁵Ṛ
ØDṫ2;0;¢;“KLMNOPQRST!?,.ZYXWVU”ṡ3Y

Try it online!

Might (still) be golfable...

///, 151 bytes

123
234
345
456
567
678
789
890
90J
0JI
JIH
IHG
HGF
GFE
FED
EDC
DCB
CBA
BAK
AKL
KLM
LMN
MNO
NOP
OPQ
PQR
QRS
RST
ST!
T!?
!?,
?,.
,.Z
.ZY
ZYX
YXW
XWV
WVU

Try it online!

Can't golf it more? This is, in a sense, <152 bytes.

Haskell, 80

mapM_(putStrLn.take 3.(`drop`"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"))[0..37]

Prolog, 131

This is probably why you never see Prolog entries. The newline is required (actually, any whitespace will do but there has to be whitespace).

z(S,L):-append(_,X,L),append(S,_,X),length(S,3).
:-forall(z(X,"1234567890JIHFEDCBAKLMNOPQRST!?,.ZYXWVU"),writef("%s\n",[X])),halt.

Ruby 69 65 62

Based on Groovy example

38.times{|i|p"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"[i,2]}

Q, 63

{(x;3)sublist"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"}'[(!)38]

Q (66 63 chars)

(((!)38),'3)sublist\:"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"

J, 66 62 45 characters

Turns out I was being too clever by half.

3]\'1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'

is all I needed all along.

Previously:

_2}.|:>(];1&|.;2&|.)'1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'

and:

38 3$($:@}.,~3$])^:(3<#)'1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'

APL, 43 characters

⍪3,/(1⌽⎕D),(⌽10↑⎕A),(10↑10⌽⎕A),'!?,.',6↑⌽⎕A

This works on Dyalog APL. I managed to save a couple characters by generating the output string (everything after ). I'll write up an explanation when I get some time!

Here's how the output looks:

      ⍪3,/(1⌽⎕D),(⌽10↑⎕A),(10↑10⌽⎕A),'!?,.',6↑⌽⎕A
 123 
 234 
 345 
 456 
 567 
 678 
 789 
 890 
 90J 
 0JI 
 JIH 
 IHG 
 HGF 
 GFE 
 FED 
 EDC 
 DCB 
 CBA 
 BAK 
 AKL 
 KLM 
 LMN 
 MNO 
 NOP 
 OPQ 
 PQR 
 QRS 
 RST 
 ST! 
 T!? 
 !?, 
 ?,. 
 ,.Z 
 .ZY 
 ZYX 
 YXW 
 XWV 
 WVU

Explanation, from right to left:

Smalltalk 102 99

1to:38 do:[:i|x:='1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'copyFrom:i to:i+2.Transcript cr show:x]

I don't know Smalltalk very well so it's a little bit strange to me. It's compiles with gst others are not tested.

C, 98 104 characters

Since no one else has done so yet, I thought I would try actually generating the string on the fly, using some kind of run-length encoding for ascending and descending runs.

EDIT: After a number of iterations, here's finally a "clever" solution that ties with the shortest "dumb" solution in C at 98 characters:

char*s="0º.ÿK»Jº ü=ÿ*ø[×",a[99],*p=a,i;main(j){for(;i-=i<8?j=*s++,*s++:8;puts(p++))p[2]=j+=i%4-1;}

The code requires an 8-bit Latin-1 encoding (ISO-8859-1 or Windows-1252), which should work fine on all commonly used platforms, but saving the source with some less popular 8-bit code page, or UTF-8 will not work.

The data string was created by the following piece of emacs lisp:

(require 'cl)
(apply 'concat
  (let ((last-remainder 0))
    (loop for (begin count step twiddle)
          in '((?1 9 +1 4) (?0 1 +2 4) (?J 10 -1 4) (?K 10 +1 0)
               (?! 1 +1 4) (?? 1 +2 4) (?, 2 +2 4) (?Z 6 -1 8))
          append (prog1 (list (char-to-string (- begin step))
                              (char-to-string 
                               (logand 255 (- last-remainder
                                              (+ (* 8 (- count 1)) (+ step 1)
                                                 twiddle)))))
                   (setq last-remainder (+ (logand twiddle 7) step 1))))))

The "twiddle" bit is used to avoid unprintable ASCII control characters in the encoded data string, and to ensure that i==0 only at the end of the output.

C, 98 characters

However, even in C you can get a short program by simply printing consecutive triplets from the original string:

main(){char s[]="12,34567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU",*p=s+2;for(;*p=p[1];puts(p-3))*++p=0;}

Scala 70 chars:

"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU".sliding(3,1).mkString("\n")

Python, 73

for i in range(38):print"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"[i:i+3]

JavaScript, 83 chars

for(i=0;i<38;)console.log('1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU'.substr(i++,3))

Decided to see if I could beat stephencarmody's solution. This is what I came up with.

Groovy, 73

(0..37).each{println"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"[it..it+2]}

All the clever stuff I tried turned out to be longer than doing it the dumb way.

Mathematica, 73

I independently arrived at the same method as everyone else:

Grid@Partition[Characters@"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU",3,1]

Perl, 63 chars

say for"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"=~/(?=(...))/g

This solution uses the say function (available since Perl 5.10.0 with the -E switch, or with use 5.010). Without it, the best I can do is 67 chars (and an extra newline at the end of the output):

print"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"=~/(?=(...))/g,$,=$/

Earlier 65-char solution:

s//1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU/;s!(?=(...))!say$1!eg

Replacing say$1 with print$1.$/ lets the code run on older perls, at the cost of 5 extra characters.

D 124 chars

import std.stdio;void main(){enum s="1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU";
foreach(i;3..s.length){writeln(s[i-3..i)]);}}

Perl, 73 characters:

print substr('1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU',$_,3),$/for 0..37

Perl, 66 characters:

say substr"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU",$_,3for 0..37

when called by:

perl -E 'say substr"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU",$_,3for 0..37'

R (75 characters)

embed(strsplit("1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU","")[[1]],3)[,3:1]

What does this do?

This produces and prints an array of characters:

> embed(strsplit("1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU","")[[1]],3)[,3:1]
      [,1] [,2] [,3]
 [1,] "1"  "2"  "3" 
 [2,] "2"  "3"  "4" 
 [3,] "3"  "4"  "5" 
 [4,] "4"  "5"  "6" 
 [5,] "5"  "6"  "7" 
 [6,] "6"  "7"  "8" 
 [7,] "7"  "8"  "9" 
 [8,] "8"  "9"  "0" 
 [9,] "9"  "0"  "J" 
[10,] "0"  "J"  "I" 
[11,] "J"  "I"  "H" 
[12,] "I"  "H"  "G" 
[13,] "H"  "G"  "F" 
[14,] "G"  "F"  "E" 
[15,] "F"  "E"  "D" 
[16,] "E"  "D"  "C" 
[17,] "D"  "C"  "B" 
[18,] "C"  "B"  "A" 
[19,] "B"  "A"  "K" 
[20,] "A"  "K"  "L" 
[21,] "K"  "L"  "M" 
[22,] "L"  "M"  "N" 
[23,] "M"  "N"  "O" 
[24,] "N"  "O"  "P" 
[25,] "O"  "P"  "Q" 
[26,] "P"  "Q"  "R" 
[27,] "Q"  "R"  "S" 
[28,] "R"  "S"  "T" 
[29,] "S"  "T"  "!" 
[30,] "T"  "!"  "?" 
[31,] "!"  "?"  "," 
[32,] "?"  ","  "." 
[33,] ","  "."  "Z" 
[34,] "."  "Z"  "Y" 
[35,] "Z"  "Y"  "X" 
[36,] "Y"  "X"  "W" 
[37,] "X"  "W"  "V" 
[38,] "W"  "V"  "U" 

Haskell, 94

main=putStr.unlines.take 38$take 3`map`iterate tail"1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU"

Javascript, 103

for(a='1234567890JIHGFEDCBAKLMNOPQRST!?,.ZYXWVU';a.length>2;a=a.substring(1))console.log(a.substr(0,3))