[Question]
  [
Given an integer from 1 to 999 inclusive, output a truthy value if it appears horizontally, vertically, or diagonally, either forwards or backwards, anywhere in the 3x3 square of digits 1-9 on a standard [number pad](https://en.m.wikipedia.org/wiki/Numeric_keypad):
```
789
456
123
```
If the number does not appear, output a falsy value.
The exact 65 numbers you need to output truthy for are:
```
1
2
3
4
5
6
7
8
9
12
14
15
21
23
24
25
26
32
35
36
41
42
45
47
48
51
52
53
54
56
57
58
59
62
63
65
68
69
74
75
78
84
85
86
87
89
95
96
98
123
147
159
258
321
357
369
456
654
741
753
789
852
951
963
987
```
Everything else is falsy.
The shortest code in bytes wins.
  
[Answer]
## JavaScript (ES6), ~~83~~ ... ~~74~~ 73 bytes
Takes input as a string.
```
n=>1/([a,b,c]=[...n].map(v=>--v+v/3|0))||45242>>(a^b)&(~c&&n<99|b*2==a+c)
```
*Saved 3 bytes thanks to ETHproductions*
### How it works
We transform the number pad by applying an offset to each digit according to the row it belongs to:
* +1 for the top row
* 0 for the middle row
* -1 for the bottom row.
All codes below are represented in hexadecimal.
```
7 8 9      8 9 A  (+1)
4 5 6  =>  4 5 6  (unchanged)
1 2 3      0 1 2  (-1)
```
Let's consider all XOR combinations of these new key codes. Contiguous keys are highlighted with brackets.
```
XOR|  0   1   2   4   5   6   8   9   A 
---+------------------------------------
 0 |  0  [1]  2  [4] [5]  6   8   9   A 
 1 | [1]  0  [3] [5] [4] [7]  9   8   B 
 2 |  2  [3]  0   6  [7] [4]  A   B   8 
 4 | [4] [5]  6   0  [1]  2  [C] [D]  E 
 5 | [5] [4] [7] [1]  0  [3] [D] [C] [F]
 6 |  6  [7] [4]  2  [3]  0   E  [F] [C]
 8 |  8   9   A  [C] [D]  E   0  [1]  2 
 9 |  9   8   B  [D] [C] [F] [1]  0  [3]
 A |  A   B   8   E  [F] [C]  2  [3]  0 
```
We can see that two keys are contiguous if and only if XORing their codes leads to one of the following values:
```
1, 3, 4, 5, 7, C, D, F
```
This list can be packed into the following binary mask:
```
  FEDCBA9876543210
  ----------------
0b1011000010111010 = 0xB0BA = 45242
```
Hence the test to determine if two key codes (a, b) correspond to two contiguous keys:
```
45242 >> (a ^ b) & 1
```
For three key codes (a, b, c), we need this additional test:
```
b * 2 == a + c
```
Example:
```
a = 0xA
b = 0x6
c = 0x2
0xB0BA >> (0xA ^ 0x6) & 1 == 0xB0BA >> 0xC & 1 == 1
=> 0xA and 0x6 are contiguous key codes
0x6 * 2 == 0xA + 0x2
=> 0xA, 0x6 and 0x2 are contiguous key codes on the same row, column or diagonal
```
### Demo
This snippet outputs the list of truthy values.
```
let f =
n=>1/([a,b,c]=[...n].map(v=>--v+v/3|0))||45242>>(a^b)&(~c&&n<99|b*2==a+c)
console.log([...Array(1000).keys()].filter(n=>n && f(n+'')).join(' '))
```
[Answer]
# Python3, 72 bytes
```
lambda n,s="123 456 789 741 852 963 42 753 86 26 159 84 ":n in s+s[::-1]
```
Input is taken as a string.
Golfing suggestions welcome! :D
[Answer]
# Befunge, ~~169~~ ~~161~~ 159 bytes
```
38*:2+"*0>DTV{51"3*\3*"kV"3*\3*"{w"3*\3*"mr"v
v:\&+*83:++66:+"c":+"?":+"$":++66:+"W":*6\*4<
_v#:\_v#*-+%+55g00*+55g02\*-g02\*-g00\`9::::p02/+55p00%"d":
0<@.!!<
```
[Try it online!](http://befunge.tryitonline.net/#code=MzgqOjIrIiowPkRUVns1MSIzKlwzKiJrViIzKlwzKiJ7dyIzKlwzKiJtciJ2CnY6XCYrKjgzOisrNjY6KyJjIjorIj8iOisiJCI6Kys2NjorIlciOio2XCo0PApfdiM6XF92IyotKyUrNTVnMDAqKzU1ZzAyXCotZzAyXCotZzAwXGA5Ojo6OnAwMi8rNTVwMDAlImQiOgowPEAuISE8&input=MTIz)
The first two lines are just pushing the list of test numbers onto the stack. This is done in order of size, since it can sometimes be easier to generate a number as an offset from the previous one in the series rather than generating it from scratch. Once we get to the larger numbers, we can also sometimes save a byte by generating them in pairs, e.g. `"kV"3*\3*` gives us 258 and 321 in nine bytes, where individually they would take five bytes each.
The main loop is on line three, executing right to left with wrap around. This just iterates through all the test numbers on the stack, comparing the value itself, value%100, and value/10. If any of those match the input number or the number <= 9 then we output 1 and exit. If there is no match, we continue looping. If we run out of test numbers on the stack then we output 0 and exit.
Thanks to [Mistah Figgins](/users/62574/mistah-figgins) for saving me a couple of bytes.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~29~~ ~~24~~ 19 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
*Saved 5 bytes thanks to @Dennis's suggestion of `K` and `Ɠ`.*
```
9s3µUŒD;;Z;ŒDµ;UKƓẇ
```
[Try it online!](http://jelly.tryitonline.net/#code=OXMzwrVVxZJEOztaO8WSRMK1O1VLxpPhuoc&input=MTIz)
### Explanation
```
9Rs3µUŒD;;Z;ŒDµ;UKƓẇ  Main link. Argument: number
9s3                   Split [1..9] into [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
   µ                  New monadic chain
    U                 Reverse the rows
     ŒD               Take the diagonals of the result
       ;              Append the original rows
        ;Z            Append the original columns
          ;ŒD         Append the original diagonals
             µ        New monadic chain
              ;U      Append the reverse of everything
                K     Join by spaces
                 Ɠẇ   Check if a line from STDIN is in the result
```
[Answer]
# Ruby, 77 bytes
```
->n{!!((s='123 456 789 147 258 369 753 951 86 62 24 48 ')+s.reverse)["#{n}"]}
```
[Answer]
# bash, 75
```
printf %s\\n 123 456 789 741 852 963 42 753 86 26 159 84|tee >(rev)|grep $1
```
outputs something and returns 0 for all the values in that list
prints nothing and returns 1 in all other cases
[Answer]
# Java, 397 bytes
```
public class Numpad {public static void main(String[] args){Scanner input=new Scanner(System.in);int in=input.nextInt();int h=in/100;int u=in%10;int t=(in%100)/10;boolean out=false;input.close();if(in<10)out=true;else if( h==0){int decider=Math.abs(t-u);if((decider==1)||(decider==3)||(decider==4))out=true;}else{if ( Math.abs(h-t) == Math.abs(t-u))out=true;}System.out.println("RESULT : "+out);}}
```
]