Output the qwerty keyboard

37

3

Given a character, output (to the screen) the entire qwerty keyboard layout (with spaces and newlines) that follows the character. The examples make it clear.

Input 1

f

Output 1

g h j k l
z x c v b n m

Input 2

q

Output 2

w e r t y u i o p
a s d f g h j k l
z x c v b n m

Input 3

m

Output 3

(Program terminates without output)

Input 4

l

Output 4

z x c v b n m

Shortest code wins. (in bytes)

P.S.

Extra newlines, or extra spaces at the end of a line are accepted.

ghosts_in_the_code

Posted 2015-11-24T10:13:53.190

Reputation: 2 907

Is a function sufficient or do you require a full program that reads/writes to stdin/stdout? – agtoever – 2015-11-24T14:47:26.217

1

@agtoever As per http://meta.codegolf.stackexchange.com/questions/7562/is-a-function-allowed, it is allowed. However, the function must still output to the screen .

– ghosts_in_the_code – 2015-11-24T14:56:27.407

@agtoever Try this link instead. http://meta.codegolf.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet

– ghosts_in_the_code – 2015-11-24T15:06:05.993

I like the ones that don't have the keyboard layout visible explicitly in the code. They should get bonus marks :) – GreenAsJade – 2015-11-25T05:46:38.740

At first i was confused by input 4, then I realised that it's a small L and not a decimal one – dwana – 2015-11-25T11:30:41.470

1are leading space before a line allowed? – Sahil Arora – 2015-11-27T21:56:39.243

1@SahilArora Nope. – ghosts_in_the_code – 2015-11-28T03:24:53.130

Might this qualify for [tag:kolmogorov-complexity] ? Not sure though – Cyoce – 2016-01-12T07:19:06.383

Answers

19

CJam, 42 40 bytes

"wertyuiop asdfghjkl zxcvbnm"q/W=S%Sf*N*

Test it here.

Explanation

"we...nm"
     e# Push the letters in order, without q. We don't need q, because it will never
     e# be part of the output.
q/   e# Split the string around the input. If the input is "q", the entire string
     e# will go into a single chunk.
W=   e# Select the last chunk.
S%   e# Split the string around spaces, discarding empty segments (only relevant for the 
     e# first segment if the input is "p" or "l").
Sf*  e# Join each line by spaces.
N*   e# Join the lines by linefeeds.

Martin Ender

Posted 2015-11-24T10:13:53.190

Reputation: 184 808

What is e#? Is it the CJam syntax for a comment? Thanks in advance. – A.L – 2015-11-25T12:38:17.147

@A.L yes it is. – Martin Ender – 2015-11-25T12:48:09.643

11

Pyth, 33 bytes

jjL\ cec."`zÈ´ýß44,ûtKÕÀ@"z\`

Note that some characters are unprintable. Try it online in the Pyth Compiler.

How it works

jjL\ cec."`z…"z\`

        ."`z…"     Unpack …, with lowest character '`' and highest character `z`.
       c      z    Split at occurrences of the input (z).
      e            Retrieve the last resulting chunk.
     c         \`  Split into rows, at backticks.
 jL\               Separate the characters of each row by spaces.
j                  Separate the rows by linefeeds.

Dennis

Posted 2015-11-24T10:13:53.190

Reputation: 196 637

Aw man, I had just created my first Pyth program ever (only 38 bytes!), then you came along... +1 BTW, I think \ is equivalent to d. – ETHproductions – 2015-11-24T18:01:11.893

Oops, I guess it's not the same... what's different? – ETHproductions – 2015-11-24T18:06:39.833

1@ETHproductions @Dennis Same reason why md5 doesn't produce 5 spaces. d is the default variable that iterates through the iterable argument of the map operator. And jL\ <list> is simply a shortcut for the map operator mj\ d<list>. – Jakube – 2015-11-24T18:58:15.217

1@Jakube Oh, that makes sense. Thanks! – Dennis – 2015-11-24T19:02:07.247

10

Perl, 56 bytes

#!perl -p
'qwertyuiop
asdfghjkl
zxcvbnm'=~/$_
?/;$_=$';s/\B/ /g

Counting the shebang as 3, input is taken from stdin. If a leading newline isn't a concern for inputs p and l, then /$_\n?/ could be replaced with a bare $_ to save 4.


Sample Usage

$ echo g|perl qwerty.pl
h j k l
z x c v b n m

$ echo v|perl qwerty.pl
b n m

primo

Posted 2015-11-24T10:13:53.190

Reputation: 30 891

2

Thank you for teaching me about \K!

– Dom Hastings – 2015-11-24T17:06:05.893

@DomHastings in this case, it wasn't really necessary for the byte count, s/.\B/$& /g would work equally well. A better example.

– primo – 2015-11-25T00:38:57.327

6

GS2, 38 37 bytes

♦wertyuiop asdfghjkl zxcvbnm♣B3$,■♪2◙

The source code uses the CP437 encoding. Try it online!

Test run

$ base64 -d > qwerty.gs2 <<< BHdlcnR5dWlvcCBhc2RmZ2hqa2wgenhjdmJubQVCMyQs/g0yCg==
$ wc -c qwerty.gs2
37 qwerty.gs2
$ echo -n f | gs2 qwerty.gs2
g h j k l
z x c v b n m

How it works

♦                                      Begin string literal.
 wertyuiop asdfghjkl zxcvbnm
                            ♣          End string literal.
                             B         Swap the string with the input.
                              3        Split the string at the input character.
                               $       Select the last chunk.
                                ,      Split the selected chunk at spaces.
                                 ■     Map over the resulting array:
                                  ♪      Push ' '.
                                   2     Join the characters, separating by ' '.
                                    ◙    Push a linefeed.

Dennis

Posted 2015-11-24T10:13:53.190

Reputation: 196 637

6

C#, 112 bytes 105 110

Count went up by 5 bytes, but more correct! Thanks @MartinBüttner!!

void c(char i){System.Console.Write(@"q w e r t y u i o p
a s d f g h j k l
z x c v b n m".Split(i)[1].Trim());}

Un-golfed

void c(char i)
{
    System.Console.Write(@"q w e r t y u i o p
    a s d f g h j k l
    z x c v b n m".Split(i)[1].Trim());
}

Johan

Posted 2015-11-24T10:13:53.190

Reputation: 161

5

JavaScript (ES6), 60 bytes

x=>[...`qwertyuiop
asdfghjkl
zxcvbnm`].join` `.split(x)[1]

Uses the same technique as most other answers. Suggestions welcome!

ETHproductions

Posted 2015-11-24T10:13:53.190

Reputation: 47 880

Can you explain why do you use the "...". I try without on JSFiddle and still working? – Awashi – 2015-11-25T15:14:17.227

@Awashi It is a spread operator. It separates the string into an array of characters. Without it the .join\ `` would do nothing and there would be no spaces in the result.

– user81655 – 2015-11-26T10:18:23.097

@user81655 Tank you – Awashi – 2015-11-26T11:26:46.523

4

TeaScript, 50 45 44 bytes

TeaScript is JavaScript for golfing.

`qwertyuiop
asdfghjkl
zxcvbnm`.s×[1]s(b)j(p)

Ungolfed and explanation

`qwertyuiop
asdfghjkl
zxcvbnm`.s(x)[1]s(b)j(p)

      // Implicit: x = input string
`...` // Take the qwerty string,
.s(x) // and split it at the input.
[1]   // Take the second item from this,
s(b)  // split it into chars,
j(p)  // and join the result with spaces.
      // Implicit: output final expression

ETHproductions

Posted 2015-11-24T10:13:53.190

Reputation: 47 880

4

Ruby, 63 57 bytes

Takes the character as command line argument: ruby keyboard.rb e

"qwertyuiop
asdfghjkl
zxcvbnm".scan$*[0]
puts$'.chars*' '

daniero

Posted 2015-11-24T10:13:53.190

Reputation: 17 193

3

JavaScript ES6, 73

f=x=>[...(k=`qwertyuiop
asdfghjkl
zxcvbnm`).slice(k.search(x)+1)].join` `

If a leading newline is not allowed when parameter is p or l, then 83

f=x=>(k=`q w e r t y u i o p
a s d f g h j k l
z x c v b n m`).slice(k.search(x)+2)

edc65

Posted 2015-11-24T10:13:53.190

Reputation: 31 086

3

Python, 83 bytes

lambda c,s="q w e r t y u i o p\na s d f g h j k l\nz x c v b n m":s[s.index(c)+2:]

Try it online

Mego

Posted 2015-11-24T10:13:53.190

Reputation: 32 998

3

Sed, 59 characters

(58 characters code + 1 character command line option.)

s/./&qwertyuiop\nasdfghjkl\nzxcvbnm/
s/(.).*\1//
s/\w/& /g

Sample run:

bash-4.3$ echo -n 'f' | sed -r 's/./&qwertyuiop\nasdfghjkl\nzxcvbnm/;s/(.).*\1//;s/\w/& /g'
g h j k l 
z x c v b n m 

manatwork

Posted 2015-11-24T10:13:53.190

Reputation: 17 865

3

Ruby, 86 87 83 71 66

puts"qwertyuiop
asdfghjkl
zxcvbnm ".split($*[0])[1].gsub /./,'\& '

The extra space after m is to prevent the program from crashing if the input is 'm'.

Thanks to @manatwork for ~16 bytes of tips

SnoringFrog

Posted 2015-11-24T10:13:53.190

Reputation: 1 709

Let me guess… Too many Python coding in the last time? – manatwork – 2015-11-24T16:01:33.177

1

Some minor syntax changes: ARGV$*; each_charchars; do..end{..}; printf$><< + % would lead to this: "qwertyuiop↵asdfghjkl↵zxcvbnm".split($*[0])[1].chars{|i|$><<"%s "%i}. More in Tips for golfing in Ruby.

– manatwork – 2015-11-24T16:09:31.620

@manatwork First time trying to golf in Ruby, thanks for the tips/link! – SnoringFrog – 2015-11-24T16:10:08.117

1I see you didn't got the hint in my first comment. In Ruby there is no need for triple quotes around multiline strings. (Actually I had no idea until now that it accepted by Ruby.) – manatwork – 2015-11-24T16:21:05.490

@manatwork Whoops. Didn't know that either; thought you meant something else. – SnoringFrog – 2015-11-24T16:26:27.003

1The leading spaces in the output are quite ugly. As . in regular expression does not match \n by default, better use that for the spacing: puts"qwertyuiop↵asdfghjkl↵zxcvbnm ".split($*[0])[1].gsub(/./,'\& '). Though the code length will remain the same. – manatwork – 2015-11-24T16:38:02.750

2

PHP, 88 bytes

<?=$m[1&ereg("$argn.(.*)",'q w e r t y u i o p
a s d f g h j k l
z x c v b n m',$m)];

Requires the -F command line option, counted as 3. Default .ini setting are assumed (you may disable your local .ini with -n).


Sample Usage

$ echo g|php -F qwerty.php
h j k l
z x c v b n m

$ echo v|php -F qwerty.php
b n m

primo

Posted 2015-11-24T10:13:53.190

Reputation: 30 891

2

Prolog (SWI), 153 133 bytes

Edit: Cut 20 bytes with tips from @Fatalize

Code

b([A,_|T],[H]):-A=H,writef('%s',[T]);b(T,[H]).
p(X):-name(X,C),b(`q w e r t y u i o p \r\na s d f g h j k l \r\nz x c v b n m`,C),!.

Explanation

p(X):-name(X,C),                                                               % Get charcode of input
      b(`q w e r t y u i o p \r\na s d f g h j k l \r\nz x c v b n m`,C),!.    % Get keyboard chars as charcodes and call b
b([A,_|T],[H]):-A=H,                                                           % If list head is input element
                writef('%s',[T]);                                              % Interpret list as charcodes and print as string
                b(T,[H]).                                                      % Else remove first element of list and try again

Examples

>p(f).
g h j k l 
z x c v b n m

>p(q).
w e r t y u i o p 
a s d f g h j k l 
z x c v b n m

Emigna

Posted 2015-11-24T10:13:53.190

Reputation: 50 798

Using SWI-Prolog, you could shorten the atom_codes part by using the backquotes which delimit string codes (so you could replace directly L in the call of b with the string). – Fatalize – 2015-11-24T13:43:35.533

@Fatalize cool! As I'm using SWI-Prolog for testing anyway, that sounds like a great idea. – Emigna – 2015-11-24T13:49:44.907

Also, using b([A,_|T],[H]):-A=H,writef('%s',[T]);b(T,[H]). instead of 2 different rules for b is 7 bytes shorter. Usually, it's always shorter to merge all rules into a single one with ORs ; instead of writing multiple rules, because you avoid repeating the predicate's name and parameters and you avoid a linefeed too ;) – Fatalize – 2015-11-24T13:51:28.207

It's been so long since I learned Prolog that I had totally forgotten that you could OR like that. Great tip! Thanks :) – Emigna – 2015-11-24T14:23:08.770

2

Befunge, 122 bytes

"m n b v c x z"25*"l k j h g f d s a"v
v1-")"g2-"U"~"q w e r t y u i o p"*25<
>-:#v_$>:#,_@ZVD0FHJ:LNP^\<>,2B48X.T6R
^1$\<

It has been tested here: Befunge-93 Interpreter.

How it works

  • 'q w e r t y u i o p\na s d f g h j k l\nz x c v b n m' is pushed on the stack.
  • The number of values to discard (hardcoded in @ZVD0FHJ:LNP^\<>,2B48X.T6R) N is pushed.
  • First N values are discarded and the remaining values are printed.

Note

I picked the encoding so the string starts with @ in order to overlap with the program. This string is generated with the following python code:

import string
letters = string.ascii_lowercase
base = 'q w e r t y u i o p a s d f g h j k l z x c v b n m'
print(''.join(chr(base.index(x) + 32 + 9 + 3) for x in letters))

Vincent

Posted 2015-11-24T10:13:53.190

Reputation: 601

1Good first answer! Welcome to Code Golf SE. (I'm new as well.) – ghosts_in_the_code – 2015-11-25T16:42:06.060

1

Japt, 49 42 41 40 38 bytes

Japt is a shortened version of JavaScript. Interpreter

`qØÆyuiop\n?dfghjkl\nzxcvbnm`qU g1 ¬qS

The ? should be the unprintable Unicode char U+0086.

How it works

          // Implicit: U = input char
`...`     // Take the compressed string and decompress it.
qU g1     // Split the string at the input and take the second item.
¬qS       // Split into chars, then join with spaces.
          // Implicit: output final expression

Now beating CJam! :) Suggestions welcome!

Non-competing version, 12 bytes

;Dv qU g1 ¬¸

As of Jan 11, I've added a cool new feature to Japt: If the program contains a leading comma, the variables ABCDEFGHIJL are redefined to various values. D is set to "QWERTYUIOP\nASDFGHJKL\nZXCVBNM", so ;Dv is enough to replace the string here.

ETHproductions

Posted 2015-11-24T10:13:53.190

Reputation: 47 880

1

Python 2, 58 67 63 bytes ##

lambda x:" ".join("qwertyuiop\nasdfghjkl\nzxcvbnm".split(x)[1])

Takes input as a string or char. Splits the string at the input and prints off everything after the split.

(First time code-golfing, please be gentle :P )

EDIT: Didn't see the additional spaces required between characters, added now

EDIT 2: Modified to be an anonymous lambda function and removing the additional split arg, saving 4 bytes

Jon Alsop

Posted 2015-11-24T10:13:53.190

Reputation: 11

Welcome to PPCG! I don't think you need the space after print, but it seems that this doesn't print the spaces between each pair of letters. – Martin Ender – 2015-11-24T16:23:20.237

Can't provide a reference right now, but when the interpreter requires extra formatting of the input, that is also included in the count. (Correct me if I am wrong, but I think this only works if the input is passed together with surrounded quotes, like "f".) – manatwork – 2015-11-24T16:26:43.693

Nice first golf. Functions are allowed by default, even anonymous ones, so it's shorter to do this as lambda s:.... I think the split doesn't need an arg of 1, since the character appears only once. This outputs spaces at the start of succeeding lines, not sure if that's allowed. – xnor – 2015-11-25T00:28:43.127

1

Mumps - 102 Bytes

Golfed script:

S A="qwertyuiopasdfghjklzxcvbnm",B=0 R P F I=1:1:$L(A) S Q=$E(A,I) W:B Q," " X:"qpl"[Q "W !" S:Q=P B=1

Ungolfed and commented:

 S A="qwertyuiopasdfghjklzxcvbnm" ; Need the qwerty order
 S B=0 ; boolean flag for printing, default to false.
 R P   ; read from stdin into P
 F I=1:1:$L(A) D   ; Count I from 1 to length of qwerty variable; do all of the following:
 . S Q=$E(A,I)     ; Extract 1 letter (at position I) from A and save in Q.
 . W:B Q," "       ; If our print flag (B) is true, print the letter in Q & a space.
 . X:"qpl"[Q "W !" ; If Q is q, p or l, write a cr/lf
 . S:Q=P B=1       ; If Q == P (stdin) change our print flag from false to true.

The rule allowing extra newlines saved me almost 10 bytes...

zmerch

Posted 2015-11-24T10:13:53.190

Reputation: 541

1

JavaScript, 88 bytes

function s(d){alert("qw e r t y u i o p\na s d f g h j k l\nz x c v b n m".split(d)[1])}

(no need in the space after the first char, as it never gets to the output)

Alerts the keyboard when you call s("some letter"). Can be also made with document.write() or console.log(), but hey, it's longer :P

Demo:

function s(d){alert("qw e r t y u i o p\na s d f g h j k l\nz x c v b n m".split(d)[1])}

s(prompt("Enter the key"));

nicael

Posted 2015-11-24T10:13:53.190

Reputation: 4 585

1You could probably save a few bytes by just using \n instead of ; in the string and getting rid of the replace. – ETHproductions – 2015-11-24T21:18:14.333

@Eth Sure, thanks! I did use the replace, because at first, without counting the line breaks, the replace would shorten. Then I've noticed that the line breaks should be there, so I've used replace again. Didn't even think it could make the code longer :D – nicael – 2015-11-24T21:24:37.050

1

Java - 107 bytes

void q(char c){System.out.print("qwertyuiop\nasdfghjkl\nzxcvbnm ".split(""+c)[1].replaceAll("\\w","$0 "));}

Ungolfed with wrapper-class reading from System.in

public class Qwerty {

    public static void main(String[] args) {
        new Qwerty().q(new java.util.Scanner(System.in).next().charAt(0));
    }
    void q(char c) {
        System.out.print("qwertyuiop\nasdfghjkl\nzxcvbnm ".split(""+c)[1].replaceAll("\\w","$0 "));
    }
}

If spaces at start-of-line were acceptable, we could go down to 99 bytes:

void q(char c){System.out.print("qwertyuiop\nasdfghjkl\nzxcvbnm ".split(""+c)[1].replace(""," "));}

janschweizer

Posted 2015-11-24T10:13:53.190

Reputation: 151

1

Ruby, 59 57 67 bytes

Added spaces between letters

puts"qwertyuiop\nasdfghjkl\nzxcvbnm".split(gets.chop)[-1].chars*' '

hbejgel

Posted 2015-11-24T10:13:53.190

Reputation: 111

This fails on input “m”. That can be easily fixed by changing the array index from -1 to 1, but then on input “m” will result nil. Which is not a problem itself, but will cause you problems when finishing your code to add spaces between the letters. – manatwork – 2015-11-25T08:55:57.943

1

O 2.2, 48 46 characters

"qwertyuiop
asdfghjkl
zxcvbnm
"i/r;s{n.U=ST?}d

Sample run:

bash-4.3$ ./o keyboard.o <<< 'f'
g h j k l 
z x c v b n m 

O, 61 characters

"qwertyuiop\nasdfghjkl\nzxcvbnm\n"i/r;""/rl{.o"\n"={}{' o}?}d

Sample run:

bash-4.3$ java xyz.jadonfowler.o.O keyboard.o <<< 'f'
g h j k l 
z x c v b n m 

manatwork

Posted 2015-11-24T10:13:53.190

Reputation: 17 865

This doesn't work on the IDE for some reason, looking into it now... – phase – 2015-11-26T01:17:39.233

"qwertyuiop\nasdfghjkl\nzxcvbnm\n"i/r;s{n.'\n=ST?}d only works on the new interpreter but is 51 bytes. – phase – 2015-11-26T01:22:10.663

The permalinks are... a work in progress :P – phase – 2015-11-26T06:10:25.163

Yup, in the libregexp directory – phase – 2015-11-26T08:56:45.080

git clone the repo, then git submodule update --init, then make – phase – 2015-11-26T09:59:42.100

Thank you, @phase. Even better, as the C interpreter supports embedded newlines, so no more literal \n. ☺ – manatwork – 2015-11-26T11:00:39.597

1

SQL (MS T-SQL), 172 bytes

CREATE PROC c @I CHAR(1) AS DECLARE @S CHAR(49) SET @S = 'w e r t y u i o p' + CHAR(13) + 'a s d f g h j k l' + CHAR(13) + 'z x c v b n m' PRINT RIGHT(@S,LEN(@S)-CHARINDEX(@I,@S))

Ungolfed:

CREATE PROC c                           -- Create a procedure named "c"
    @I CHAR(1)                          -- Which is invoked with a single character input (@I)
AS

DECLARE @S CHAR(49) = 'w e r t y u i o p' + CHAR(13) + 'a s d f g h j k l' + CHAR(13) + 'z x c v b n m' -- Initialise the entire output omitting "q " as @S
PRINT RIGHT(@S,LEN(@S)-CHARINDEX(@I,@S))    -- Use the charindex funtion to effectively substring @S

I'm new here, only just discovered this site. No idea if I've posted correctly or if T-SQL is allowed but I know the procedure above works.

Steve Matthews

Posted 2015-11-24T10:13:53.190

Reputation: 121

0

Gema, 56 characters

?=@subst{\\A\*?=\;\?=\? ;qwertyuiop\nasdfghjkl\nzxcvbnm}

Sample run:

bash-4.3$ echo -n 'f' | gema '?=@subst{\\A\*?=\;\?=\? ;qwertyuiop\nasdfghjkl\nzxcvbnm}'
g h j k l 
z x c v b n m 

manatwork

Posted 2015-11-24T10:13:53.190

Reputation: 17 865

0

8086 machine code + DOS, 61 bytes

Hexdump (with ASCII view on the right):

B8 1E 01 8B F8 CD 21 B1 1F F2 AE 8B F7 AC 8A D0 ......!.........
B4 02 CD 21 80 E2 20 74 02 CD 21 E2 F0 C3 71 77 ...!.. t..!...qw
65 72 74 79 75 69 6F 70 0D 0A 61 73 64 66 67 68 ertyuiop..asdfgh
6A 6B 6C 0D 0A 7A 78 63 76 62 6E 6D 0D          jkl..zxcvbnm.

Assembly source code (can be assembled with tasm):

    .MODEL TINY

    .CODE
    org 100h

    MAIN PROC

    mov ax, offset qwerty ; sets ah=1 (coincidence)
    mov di, ax      ; di points to the string
    int 21h         ; reads a char from keyboard into al

    mov cl, 31      ; cx is the length of the string
    repne scasb     ; look for the char
    mov si, di      ; si now points beyond the found char

myloop:
    lodsb           ; load a char
    mov dl, al
    mov ah, 2
    int 21h         ; output the char

    and dl, 20h     ; if it's a letter, set it to a space
    jz print_done   ; if it's not a letter, don't print a space
    int 21h         ; if it's a letter, print a space
print_done:
    loop myloop     ; repeat until end of string

    ret

qwerty db 'qwertyuiop',13,10,'asdfghjkl',13,10,'zxcvbnm',13

    MAIN ENDP
    END MAIN

Two fun things here:

  1. The offset of the qwerty string is 0x011e. The upper byte of it is 1, which is the DOS function number for character input. This saves 1 byte in the code.
  2. All lower-case letters have bit 5 set. When doing an AND with 0x20, they are all turned into a space, which is then printed. If the previous char was an end-of-line byte, it gets turned into 0, and no space is output. This is used to avoid the nonsensical sequence 0d 20 0a 20 at end of line.

One almost-fun thing:

I tried to search for the input char starting at address 0 (that decreased program size by 2 bytes), instead of the usual place (start of the string). This almost worked; however, it failed for input t, because the code itself contains the byte t (as part of the encoding of a conditional jump). So for t, it would output a few junk bytes:

output

anatolyg

Posted 2015-11-24T10:13:53.190

Reputation: 10 719

0

, 32 chars / 79 bytes

⟦ɘƄ瀛ذ鸊ް΀ꀆဓƘ᳀ᘁ堍怍訁码聮Ęݠⶰ䀀#]ø⬭Čï⎖1

Try it here (Firefox only).

At least I'm winning in char count... (Byte count's a different story.)

Oh yeah, just realized that I implemented index shortcuts (⎖1 instead of [1]) awhile back. Silly me!

Mama Fun Roll

Posted 2015-11-24T10:13:53.190

Reputation: 7 234

What language is this? or is it literally this: http://i.imgur.com/WC7XvYs.png (and is there documentation) it's weird, aha!

– ʰᵈˑ – 2015-11-26T11:51:43.380

This is ESMin. Letters are in doublestruck, so you might have trouble seeing them. See github.com/molarmanful/ESMin (docs are outdated, though). – Mama Fun Roll – 2015-11-26T15:44:54.987

0

C++, 129, 112 97 bytes

#include<string>
#include<cstdio>
void o(char c){puts(strstr("qwertyuiopasdfghjklzxcvbnm",&c));}

Ungolfed:

#include<string>
#include<cstdio>
void o(char c)
{
    puts(strstr("qwertyuiopasdfghjklzxcvbnm",&c));
}

Tas

Posted 2015-11-24T10:13:53.190

Reputation: 593

You could shave off 17 bytes by using puts instead of std::cout<< – James – 2015-11-26T05:36:33.950

@DJMcMayhem Thanks! An excellent point: for some reason I thought I would still need an #include for puts, but evidently I do not! – Tas – 2015-11-26T05:40:21.207

Also, this is another 12 shorter.

– James – 2015-11-26T05:48:08.007

Thanks! I didn't even know strstr was a thing. – Tas – 2015-11-26T05:55:05.657

I think that's a little bit overgolfed. You need <stdio.h> for strstr. – James – 2015-11-26T06:10:42.370

@DJMcMayhem Hmm I managed to compile it just fine in VS2013 by simply #include<string, but you're right. I will update the answer. Thanks for sticking it through with me!

– Tas – 2015-11-26T21:10:51.900

Aren't there missing some newlines and spaces from the output? – manatwork – 2015-11-27T07:33:26.623

0

Batch, 206 + 2 = 208 bytes

Because this uses delayed expansion you need to invoke it with CMD /V /C keyboard.cmd <letter>, so adding 12 for the /V switch.

@echo off
set a=q w e r t y u i o p
set b=a s d f g h j k l
set c=z x c v b n m
if not "!a:*%1 =!"=="!a!" echo !a:*%1 =!
if not "!a:*%1=!!b:*%1 =!"=="!a!!b!" echo !b:*%1 =!
if not %1==m echo !c:*%1 =!

Neil

Posted 2015-11-24T10:13:53.190

Reputation: 95 035

I'm afraid the command line option would count 1 if cmd would accept it as /VC, like POSIX tools do. But as I know /V requires its own /, which also gets counted. – manatwork – 2015-11-27T07:37:35.567

0

Python, 109 bytes

I know its a bit large but its all I know how to do right now!

def kb(c): 
 s = "q w e r t y u i o p \n a s d f g h j k l \n z x c v b n m"
 a = s.split(c)
 print(a[1])

Ashwin Gupta

Posted 2015-11-24T10:13:53.190

Reputation: 471

I don't think you need the call to kb() at the end; defining the function is enough. Also, 1 space of indentation is enough. After making these changes, I get 108 bytes, using this site.

– ETHproductions – 2015-11-27T20:51:40.417

@ETHproductions wow I didn't know that once space thing. (New to python). Thanks again for your help! – Ashwin Gupta – 2015-11-27T21:03:13.370

0

PHP, 83 bytes

<?=trim(explode($argv[1],"qw e r t y u i o p
a s d f g h j k l
z x c v b n m")[1]);

Takes the letter from the command line, like:

$ qwerty.php y

insertusernamehere

Posted 2015-11-24T10:13:53.190

Reputation: 4 551

0

Bash, 80 bytes

x="qwertzuiop\nasdfghjkl\nyxcvbnm"&&echo -e ${x#*$1}|sed 's/./& /g'

Try it yourself, either replace $1 with desired character or make a #!/bin/bash script.

Here are some samples from cygwin:

$x="qwertzuiop\nasdfghjkl\nyxcvbnm"&&echo -e ${x#*q}|sed 's/./& /g'
w e r t z u i o p
a s d f g h j k l
y x c v b n m

$x="qwertzuiop\nasdfghjkl\nyxcvbnm"&&echo -e ${x#*m}|sed 's/./& /g'

$x="qwertzuiop\nasdfghjkl\nyxcvbnm"&&echo -e ${x#*h}|sed 's/./& /g'
j k l
y x c v b n m

It's not the shortest, but I'm still proud of it!

Cajova_Houba

Posted 2015-11-24T10:13:53.190

Reputation: 21

0

Bash, 74 bytes

Took a different approach than @Cajova_Houba's answer, so I posted it separately. Ended up not being too much shorter because I initially forgot to deal with space-separating the output.

cut -d"$1" -f2<<<"qwertzuiop asdfghjkl yxcvbnm"|tr ' ' "\n"|sed 's/./& /g'

Takes input as a command line argument, or just replace $1 manually and run it straight from terminal.

SnoringFrog

Posted 2015-11-24T10:13:53.190

Reputation: 1 709

0

Hassium, 114 Bytes

func main(){k="qwertyuiop\nasdfghjkl\nzxcvbnm\n"foreach(l in k.substring(k.index(input())))print(l!="\n"?l+" ":l)}

Run online and see expanded with test case here

Jacob Misirian

Posted 2015-11-24T10:13:53.190

Reputation: 737