[Question]
  [
[![enter image description here](https://i.stack.imgur.com/nhS8q.jpg)](https://i.stack.imgur.com/nhS8q.jpg)
Normally, challenges are scored in bytes, or sometimes Levenshtein distance, but for this one we're using keyboard distance -- the number of keys between the keys used to type the program (use the above keyboard as the definitive reference). For example, the distance between `A` and `F` is 3, because the path is `A`=>`S`=>`D`=>`F`. The distance between `N` and `5` is 4, because no matter what path you take, it requires at least 4 steps. Your task is to output the following (not including trailing spaces), with as small a keyboard distance as possible:
```
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
```
## Wrapping:
To make your life easier, certain keys can wrap around the keyboard. `Left Shift` wraps to `Right Shift`, `Caps Lock` wraps to `Enter`, `Tab` wraps to `\` and `~` wraps to `Backspace`. For example, the distance between `Q` and `P` is 5, because `Q`=>`Tab`=>`\`=>`]`=>`[`=>`P`.
**Note:** Wrapping only works horizontally -- you can not step from, say, `\` to `Caps Lock`
## Scoring:
**Score = Keyboard distance + byte count**
## Example Calculation:
`print(5);`
* `p`=>`r` == 6
* `r`=>`i` == 4
* `i`=>`n` == 2
* `n`=>`t` == 3
* `t`=>`(` == 4
* `(`=>`5` == 4
* `5`=>`)` == 5
* `)`=>`;` == 2
**Total:** 30 + 9 = **39**.
## Notes:
1. Lowercase and uppercase letters count as the same key. If a key has two symbols on it (like `7` and `&`), they also count as the same key, no need to include pushing shift.
2. Unfortunately, if your code requires symbols that are not on the keyboard you cannot use it.
3. On the keyboard image, the top row can be ignored. The only key you can use on the bottom row is `Space`
4. Keys must be inputted in order, you can't use the arrow keys to move the caret and then input a key.
## Score Calculator:
* **Updated on 12/27 to fix ```=>`]` and related miscalculations. Check your scores again, and they will likely be smaller (hopefully not bigger!)**
Paste in your code here to calculate the score. Let me know if you ever get an error or it prints out the wrong number.
```
var keys = ["~1234567890-=←","\tqwertyuiop[]\\","↑asdfghjkl;\'\n","Lzxcvbnm,./R",
"AB      CDEF"];
var con =["`!@#$%^&*()_+{}|:\"<>?","~1234567890-=[]\\;\',./"];
function hexagon(k) {
  if(k === " ") return ["x","c","v","b","n","m",","];
  var p = pos(k);
  if(p === -1) return false;
  var row = p[0],col = p[1];
  var hexagon = [char(row,col-1,1),char(row-1,col),char(row-1,col+1),char(row,col+1,1),char(row+1,col),char(row+1,col-1)];
  return hexagon;
}
function char(r,c,wrap) {
  if(r < 0 || r >= keys.length) return "";
  if(r === keys.length-1 && 1 < c && c < 8) return " ";
  if(wrap) {
    if(c === -1) c = keys[r].length-1;
    if(c === keys[r].length) c = 0;
  }
  return keys[r].charAt(c);
}
function pos(c) {
    var row = -1, col = -1;
  for(var i = 0;i<keys.length;i++) {
    col = keys[i].indexOf(c)
    if( col != -1) { row = i; break;}
  }
  if(row === -1) return -1;
  return [row,col];
}
function dist(a,b,s,w) {
  if(typeof a === "object") {
    var list = [];
    for(var i = 0;i<a.length;i++) {
      list[i] = dist(a[i],b,s,w);
    }
    return list;
  }
  
	if(a==="") return Infinity;
  if(a===b) return 0;
  
 
  var p = pos(a);
  var q = pos(b);
  
  if(!w && a!==" ") {
    var chars = keys[p[0]].length;
    var opp = char(p[0],p[1] < chars/2 ? chars-1 : 0);
    return Math.min(dist(a,b,s,true),dist(a,opp,s,true)+dist(opp,b,s,true));
  }
  
   if(!s) { return Math.min(dist(a,b,true,w),dist(a," ",true,w)+dist(" ",b,true,w));}
  
   var h = hexagon(a);
  if(a === " ") return 1 + Math.min(...dist(h,b,true,w));
 if(p[0]<q[0]) {
  return 1 + Math.min(dist(h[4],b,s,w),dist(h[5],b,s,w)); 
  }
  else if(p[0] > q[0]) {
  return 1 + Math.min(dist(h[1],b,s,w),dist(h[2],b,s,w));
    }
  	if(b===" ") return Math.min(Math.abs(p[1]-7),Math.abs(2 - p[1]));
    var d = Math.abs(p[1]-q[1]);
    return Math.min(d,keys[p[0]].length-d);
  
  
  
  
}
function getTotalDistance(str) {
	for(var i = 0;i<con[0].length;i++)
  	str = str.replace(new RegExp("\\"+con[0].charAt(i),"g"),con[1].charAt(i));
  str = str.toLowerCase();
  var total = 0;
  for(var i = 0;i<str.length-1;i++) {
  	total += dist(str[i],str[i+1]);
  }
  return total;
} 
enter.onclick = function() {
 var a = getTotalDistance(program.value);
 var b = program.value.length;
 len.textContent = a;
 count.textContent = b;
 total.textContent = a+b;
};
```
```
<textarea rows=15 cols=40 id="program"></textarea>
<input type="submit" id="enter"/>
<div>
<div>Key distance: <span id="len"></span></div>
<div>Byte count: <span id="count"></span></div>
<div>Total: <span id="total"></span></div>
</div>
```
### Related:
* [The very weird word counter](https://codegolf.stackexchange.com/questions/52439/the-very-weird-word-counter)
* [Output the qwerty keyboard](https://codegolf.stackexchange.com/questions/64639/output-the-qwerty-keyboard)
* [DISARM THE B.O.M.B.!](https://codegolf.stackexchange.com/questions/31552/disarm-the-b-o-m-b)
  
[Answer]
# [Unary](https://esolangs.org/wiki/Unary), score ~6.1\*10618
`6103247739090735580402225797524292167653462388595033897325606983093527722629493568418069722646005695215642120674994001348606253869287599178270707482456199630901069511698694317195626565008736452130034232375778047932461822258369348260249011643486476832847755830117284465136723525376668555270734061914837886192012601522703308221225195058283657800958507281265116257152529161080096092081620384043514820427911786442536988705847468796481108000358361636640985892696216392434604543586511103835032034494033598102606339253132146827455065586119645920456668064941286708686113567081095434338440184737976711767750474398662381256908308 zeros`
Not the most "creative" solution but it took my computer ~3 minutes to convert the base 2 representation of this to base 10
---
This *used to* have a **score of 0**, but the scoring rules changed.
Code Length: ~6.1\*10618
Key Distance: 0
[Answer]
# [Japt](http://ethproductions.github.io/japt?v=master&code=IlFXRVJUWVVJT1AKQVNERkdISktMCidaWENWQk5NInEgcVMgcicnIg==&input=), score ~~123~~ ~~119~~ ~~118~~ ~~116~~ 106
~~42~~ ~~41~~ 40 bytes + ~~81~~ ~~78~~ ~~77~~ ~~75~~ 66 distance
```
"QWERTYUIOP
ASDFGHJKL
'ZXCVBNM"q qS r''"
```
(proper output in the "output" box)
[Answer]
# JavaScript (ES6), score 188
```
alert([...`QWERTYUIOP
ASDFGHJKL
`," Z",..."XCVBNM"].join` `)
```
Only just barely gets a better score than `alert`ing the output string but it's the best approach I could find... : /
Bytes: `60`
Key Distance: `128`
[Answer]
# Pyth, score ~~107~~ ~~106~~ 102
```
:jd"QWERTYUIOP
ASDFGHJKL
]XCVBNM""]"" Z
```
[Try it online.](https://pyth.herokuapp.com/?code=%3Ajd%22QWERTYUIOP%0AASDFGHJKL%0A%5DXCVBNM%22%22%5D%22%22+Z&debug=0)
[Answer]
# Bash + Sed, 151
```
sed 'sb *.b& bg'<<<'QWERTYUIOP
 ASDFGHJKL
  ZXCVBNM'
```
[Answer]
# Python, ~~157~~, ~~156~~, ~~211~~, 221 points
Key Distance: 157
Bytes: 64
Ergo, total score is 221.
```
l=' '.join('QWERTYUIOP\nASDFGHJKL\nZXCVBNM')
print l[:42],l[42:]
```
Prints the string but has to add an extra space. :( now longer.
Why @Pietu, why did you do this to me?
[Answer]
# JavaScript, score 156 ~~187~~
```
[...`QWERTYUIOP
ASDFGHJKL`].join` `+`
  Z X C V B N M`
```
Not bad for JavaScript
[Try it online](http://vihanserver.tk/p/esfiddle/?code=%5B...%60QWERTYUIOP%0AASDFGHJKL%60%5D.join%60%20%60%2B%60%0A%20%20Z%20X%20C%20V%20B%20N%20M%60)
---
With alert, **score 186**
```
alert([...`QWERTYUIOP
ASDFGHJKL`].join` `+`
  Z X C V B N M`)
```
[Answer]
# [Jolf](https://github.com/ConorOBrien-Foxx/Jolf), 118 + 51 = 169
[Try it here!](http://conorobrien-foxx.github.io/Jolf/#code=UiBteyJRV0VSVFlVSU9QJ0FTREZHSEpLTCdaWENWQk5NIiNETisqUycgUkgnIH0iXG4i) (underscores in explanation used to denote a used space)
```
R m{"QWERTYUIOP'ASDFGHJKL'ZXCVBNM"#DN+*S' RH' }"\n"
 _m                                                 map
   {"QWERTYUIOP'ASDFGHJKL'ZXCVBNM"#                  that array
                                   DN         }      with this function
                                     +*S'_            that concats (index many) spaces
                                          RH'_         with the inner array joined by spaces
R                                                    and join that
                                                      "\n"  with newlines
```
# Jolf, update post-question, 76 + 21 = 97
Try it [here](http://conorobrien-foxx.github.io/Jolf/#code=UiBtcEhETisqUycgUkgnIH0iXG4i)! Again, I don't often update my code until relevant. Still fun.
```
R mpHDN+*S' RH' }"\n"
 _m                   map
   pH                 the keyboard array [["Q","W",...,"P"],["A",...,"L"],["Z",...,"M"]]
     DN         }      with this function
       +*S'_            that concats (index many) spaces
            RH'_         with the inner array joined by spaces
R                     and join that
                 "\n"  with newlines
```
[Answer]
# Bash + sed, score ~~202~~ 200
```
sed 's/\([^ ]\)/\1 /g'<<F
QWERTYUIOP
 ASDFGHJKL
  ZXCVBNM
F
```
[Answer]
# Python, score 185
```
print" ".join("QWERTYUIOP\nASDFGHJKL\n")+"  Z X C V B N M"
```
]