| Bytes | Lang | Time | Link |
|---|---|---|---|
| 147 | Perl 5 F | 240812T170253Z | Xcali |
| 020 | Japt | 240811T152510Z | Shaggy |
| 045 | Vyxal 3 | 240812T002808Z | bb94 |
| 067 | Uiua | 240811T114839Z | nyxbird |
| 156 | Clojure | 171212T132001Z | NikoNyrh |
| 1731 | PHP | 171130T133124Z | Titus |
| 060 | Pyth | 151127T030712Z | Maltysen |
| 227 | C# | 151127T040550Z | noisyass |
| 078 | Japt | 151127T032821Z | ETHprodu |
Perl 5 -F, 147 bytes
map{$c=reverse($b=$_.$F[++$i]);$r.=grep/$b|$c/,1234567890,QWERTYUIOP,ASDFGHJKL,ZXCVBNM,ZAQ1,XSW2,CDE3,VFR4,BGT5,NHY6,MJU7,KI8,LO9,P0}@F;say$r=~/11/
Japt, 20 bytes
Takes input in uppercase
;ø4o!z9õ ¬+DiRiV¹cã3
;ø4o!z9õ ¬+DiRiV¹cã3 :Implicit input of string
ø :Does it contain any element of
4o : Range [0,4)
!z : Map each X to the following rotated 90º X times
9õ : Range [1,9]
¬ : Join
+ : Append
; D : "QWERTYUIOP\nASDFGHJKL\nZXCVBNM"
i : Prepend
R : Newline
i : Prepend
V : Second input variable (defaults to 0)
¹ :End map
c :Flat map
ã3 : Substrings of length 3
Vyxal 3, 45 bytes
Returns the number of (possibly overlapping) runs.
9zṘ“"ᶜ½(ẆNᴳṀ⊻ᵡHṗᵏ₀Ṃ]Ḅġ„+£ƛ¥$Ḟ:₀Ṡ$₀%;}ᵃȧṠ1=ᵃ∧∑
Explanation
9zṘ“"ᶜ½(ẆNᴳṀ⊻ᵡHṗᵏ₀Ṃ]Ḅġ„+£ƛ¥$Ḟ:₀Ṡ$₀%;}ᵃȧṠ1=ᵃ∧∑
9zṘ“ # Push "1234567890"
"ᶜ½(ẆNᴳṀ⊻ᵡHṗᵏ₀Ṃ]Ḅġ„ # Base-252 compression of "qwertyuiopasdfghjkl zxcvbnm"
9zṘ“"ᶜ½(ẆNᴳṀ⊻ᵡHṗᵏ₀Ṃ]Ḅġ„+£ # Push "1234567890qwertyuiopasdfghjkl zxcvbnm" and store in register
ƛ } # For each character of the input...
¥$Ḟ # Find its index i in the register
:₀Ṡ$₀%; # Get [i // 10, i % 10]
ᵃȧ # Get the absolute difference between each adjacent pair of elements
Ṡ1= # Get whether each element has a sum of 1
ᵃ∧∑ # Get the number of adjacent elements that are both 1
💎
Created with the help of Luminespire.
Uiua, 67 bytes
↥∩(/↥♭≡⌕⊙¤◫3),⊙:∩[≡⇌.]⍉.↯4_∞⊂+@1⇡9"0qwertyuiopasdfghjkl zxcvbnm "
↥∩(/↥♭≡⌕⊙¤◫3),⊙:∩[≡⇌.]⍉.↯4_∞⊂+@1⇡9"0qwertyuiopasdfghjkl zxcvbnm "
"0qwertyuiopasdfghjkl zxcvbnm " # push the flattened keyboard without 1-9
⊂+@1⇡9 # prepend 1-9
↯4_∞ # shape into a 4x10 array
∩ ⍉. # for both it and its transposition,
[≡⇌.] # create an array with reversed rows
∩( ) # for both arrays,
⊙¤◫3 ,⊙: # get the 3-wise windows of the input,
≡⌕ # search for them in each row,
/↥♭ # and get the maximum of the whole array
↥ # take the maximum of both arrays
```
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.
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.
Pyth - 66 62 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
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 :(
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