One aspect of password strength testing is runs of adjacent letters on the keyboard. In this challenge, a program must be created that returns true if a string contains any runs of adjacent letters.

## What counts as a run of adjacent letters?

For this simplified version of a password strength tester, a run of adjacent characters is 3 or more letters which are next to each other in a single direction (left, right, above or below) on a QWERTY keyboard. For the purpose of this challenge the layout of the keyboard looks like this:

1234567890
QWERTYUIOP
ASDFGHJKL
ZXCVBNM


In the diagram above Q is below 1 but not below 2, so a string that contains 1qa or aq1 anywhere inside it would make the program return true, but 2qa would not.

## Input

The password string to check. It will only contain the characters [0-9a-z] or [0-9A-Z] (your choice).

## Output

The program must return a truthy value if the password contains one or more runs of adjacent keys, or falsey if it contains none.

## Examples

The following inputs should output true:

• asd
• ytrewq
• ju7
• abc6yhdef

And these inputs should output false:

• abc
• aaa
• qewretry
• zse
• qwdfbn
• pas

## Rules

• Answers may be complete programs or functions.
• Standard loopholes are disallowed.
• This is , lowest score (in bytes) wins!

# Pyth - 6662 60 bytes

Pretty straightforward approach. Checks if any of substrings len 3 are in any of the rotations of the keyboard. Will be using base encoding for keyboard.

.E}Rjb+J+Kc+jkS9"0
qwertyuiop
asdfghjkl
zxcvbnm"b.tKN_MJ.:z3

• @user81655 fixed, and saved two bytes. – Maltysen Nov 27 '15 at 4:58

# Japt, 78 bytes

Japt is a shortened version of JavaScript. Interpreter

V=1oA ¬+0\nqØÆyuiop\n?dfghjkl \nzxcvbnm;1+¡Y©(((VbX -VbUgY-1)-5 a -5 %A a)bB


Outputs 0 for falsey cases; otherwise, a positive integer. The ? should be replaced with the unprintable Unicode char U+0086, or if you don't want to go to all that trouble, just as.

### How it works

V=1oA q +"0\nqwertyuiop\nasdfghjkl \nzxcvbnm";1+Um@Y&&(((VbX -VbUgY-1)-5 a -5 %A a)bB
// Implicit: U = input string
V=1oA q    // Set variable V to the digits 1-9, plus
+"...";    // this string.
Um@        // Take U and map each character X and its index Y with this function:
Y&&        //  If Y is 0, return Y; otherwise,
VbX -      //  take the index of X in V, subtract
VbUgY-1    //  the index of (char at position Y - 1 in U) in V,
-5 a -5    //  subtract 5, take the absolute value, subtract 5 again,
%A a       //  take modulo by 10, then take the absolute value.
//  This returns 1 for any pair of characters that is adjacent
//  within V, horizontally or vertically.
bB +1      // Take the index of 11 in the result and add one.
// Implicit: output last expression


## C#, 227

int h(string k){var q="1234567890,QWERTYUIOP,ASDFGHJKL,ZXCVBNM,1QAZ,2WSX,3EDC,4RFV,5TGB,6YHN,7UJM,8IK,9OL,";int i=0,j=0;for(;i<k.Length-2;i++)if((q+String.Concat(Enumerable.Reverse(q))).Contains(k.Substring(i,3)))j=1;return j;}


0 is falsey, 1 is truthy. Concatenated all keys horizontal and vertical, and reversed, and checks if any of 3 chars of input is contained within.

C# is really verbose, gotta dive into other languages :(

# PHP, 173+1 bytes

while(~$argn[$i+2])($p=preg_match)($r=_.join(".{10}",str_split(($t=substr($argn,$i++,3))))."|$t"._,$d=_1234567890_qwertyuiop_asdfghjkl__zxcvbnm)||$p($r,strrev($d))?die(1):0;


Run as pipe with -nR with lowercase input or try it online.

## Clojure, 156 bytes

#(some(set(for[R[["1234567890""QWERTYUIOP""ASDFGHJKL.""ZXCVBNM..."]]R[R(apply map list R)]r R p(partition 3 1 r)p((juxt seq reverse)p)]p))(partition 3 1 %))


This was a quite interesting task to implement.