8
1
Assume an simple keyboard with this layout:
1 2 3 4 5 6 7 8 9 0
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 . , ? !
Peter's keyboard pattern can be generated by starting at the top left of the keyboard, and displays the first three characters and a newline. It shifts over one character and displays the second, third, and fourth key. Once it reaches the end of a row it continues at the end of the next row and goes backwards, until it reaches the start of that row and then goes forward on the next row, and so on until it reaches the beginning of the last row.
This is Peter's keyboard pattern:
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
Write a program which accepts no input and displays Peter's keyboard pattern. The program must be smaller than 152 bytes, i.e. the size of the string it outputs.
This is code golf, so the shortest solution wins.
The 152 byte limit seems unnecessary--hardcoding the output with no compression whatsoever is bad golfing anyways. It could also potentially bar languages such as brainf**k, where large programs are almost always the occurance but there still could be some clever golfing going on. – Zwei – 2016-10-03T22:36:08.003
Even in Golfscript I'm struggling to come up with a shorter way of generating the 40-character base string. – Peter Taylor – 2011-12-02T08:18:20.830
@PeterTaylor I was expecting somebody to use some sort of list comprehension, like
[1..9 0 J..A K..T ! ? , . Z..U]
. – Peter Olson – 2011-12-03T17:02:28.753You can use
echo {1..9} "0" {J..A} {K..T} '!?,.' {Z..U}|sed 's/ //g'
in bash, but need already 13 chars to append a sed-command, to remove blanks. This makes 57 chars, and no triple has been build so far. With sed's hold-command, it should be possible, but in 6 chars, to beat the perl-solution? – user unknown – 2011-12-09T00:38:43.957