# Output the qwerty keyboard

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.

• Is a function sufficient or do you require a full program that reads/writes to stdin/stdout? Nov 24, 2015 at 14:47
• @agtoever As per meta.codegolf.stackexchange.com/questions/7562/…, it is allowed. However, the function must still output to the screen . Nov 24, 2015 at 14:56
• @agtoever Try this link instead. meta.codegolf.stackexchange.com/questions/2419/… Nov 24, 2015 at 15:06
• are leading space before a line allowed? Nov 27, 2015 at 21:56
• @SahilArora Nope. Nov 28, 2015 at 3:24

# 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  # 𝔼𝕊𝕄𝕚𝕟, 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! • What language is this? or is it literally this: i.imgur.com/WC7XvYs.png (and is there documentation) it's weird, aha! – ʰᵈˑ Nov 26, 2015 at 11:51 • This is ESMin. Letters are in doublestruck, so you might have trouble seeing them. See github.com/molarmanful/ESMin (docs are outdated, though). Nov 26, 2015 at 15:44 # 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)); }  • You could shave off 17 bytes by using puts instead of std::cout<< Nov 26, 2015 at 5:36 • @DJMcMayhem Thanks! An excellent point: for some reason I thought I would still need an #include for puts, but evidently I do not! – Tas Nov 26, 2015 at 5:40 • Also, this is another 12 shorter. Nov 26, 2015 at 5:48 • Thanks! I didn't even know strstr was a thing. – Tas Nov 26, 2015 at 5:55 • I think that's a little bit overgolfed. You need <stdio.h> for strstr. Nov 26, 2015 at 6:10 ## 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 =!  • 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. Nov 27, 2015 at 7:37 ## 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])  • 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. Nov 27, 2015 at 20:51 • @ETHproductions wow I didn't know that once space thing. (New to python). Thanks again for your help! Nov 27, 2015 at 21:03 # 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!

# 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


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

drop 2.snd.(span"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").(/=)

f(c){puts(strchr("qwertyuiop\nasdfghjkl\nzxcvbnm",c)+1);}