| Bytes | Lang | Time | Link |
|---|---|---|---|
| 093 | Rust | 240922T124726Z | bzr |
| 077 | JavaScript | 201024T193408Z | bzr |
| 057 | C gcc | 210119T181624Z | anotherO |
| 053 | K ngn/k | 201023T173311Z | coltim |
| 079 | Haskell | 201025T170711Z | lynn |
| 038 | Husk | 201023T153431Z | Razetime |
| 035 | Husk | 201023T154711Z | Dominic |
| 012 | Japt hR | 201023T141117Z | Shaggy |
| 038 | Japt | 151124T153745Z | ETHprodu |
| 114 | Hassium | 151130T171805Z | Jacob Mi |
| 074 | Bash | 151130T162727Z | SnoringF |
| 083 | PHP | 151129T004820Z | insertus |
| 080 | Bash | 151129T033954Z | Cajova_H |
| 109 | Python | 151127T204408Z | Ashwin G |
| 044 | TeaScript | 151124T171207Z | ETHprodu |
| nan | Batch | 151126T224634Z | Neil |
| 046 | O 2.2 | 151125T112248Z | manatwor |
| 097 | C++ | 151126T052938Z | Tas |
| 172 | SQL MS TSQL | 151126T105438Z | Steve Ma |
| 056 | Perl | 151124T105404Z | primo |
| 088 | JavaScript | 151124T190819Z | nicael |
| 122 | Befunge | 151125T162709Z | Vincent |
| nan | Ruby | 151124T230137Z | hbejgel |
Rust, 93 bytes
let f=|c:char|"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(c).nth(1).unwrap();
JavaScript, 77 bytes
alert(`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(prompt())[1])
Fiddle
K (ngn/k), 53 bytes
{` 0:1_*|x\"\n"/" "/'$$`qwertyuiop`asdfghjkl`zxcvbnm}
Uses "\n"/" "/'$$`...`...`... to (slightly) compress "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".
It then splits that string on the input character, taking the remainder that occurs after that character.
Haskell, 79 bytes
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").(/=)
Husk, 29 35 bytes
Edit +6 bytes when I realised that the letters need to be separated by spaces
¶mJ' ¶!2x¨qw²yuiop₄sdfghjkl¶zxcvbnm
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.
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
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.
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, 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!
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])
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
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 =!
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
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));
}
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.
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
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"));
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))
Ruby, 59 57 67 bytes
Added spaces between letters
puts"qwertyuiop\nasdfghjkl\nzxcvbnm".split(gets.chop)[-1].chars*' '