[Question]
  [
A "Giza number", also colloquially known as a [Timmy Number](http://chat.stackexchange.com/transcript/message/33544457#33544457) is any number where the digits represent a pyramid ([A134810](http://oeis.org/A134810)). For example, "12321" is a giza number because it can be visualized like this:
```
  3  
 2 2
1   1
```
However, something like "123321" is not a Giza number because there are two digits at the top of the pyramid
```
  33  
 2  2
1    1
```
In other words, a number is a Giza number if all of the following conditions are met:
* It has an odd number of digits, and the center digit is the largest
* It's palindromic (the same read forwards or backwards), and
* The first half of the digits are strictly increasing by one. (Since it must be palindromic, this means the second half of the digits must be strictly decreasing by one)
You must write a full program or a function that takes a positive integer as input, and determine if it is a Giza number or not. You may take the input as a string or as a number. If it *is* a Giza number, output a [truthy value](http://meta.codegolf.stackexchange.com/questions/2190/interpretation-of-truthy-falsey). Otherwise, a falsy value.
There are a total of 45 Giza numbers, so any one of these inputs should result in a truthy value:
```
1
2
3
4
5
6
7
8
9
121
232
343
454
565
676
787
898
12321
23432
34543
45654
56765
67876
78987
1234321
2345432
3456543
4567654
5678765
6789876
123454321
234565432
345676543
456787654
567898765
12345654321
23456765432
34567876543
45678987654
1234567654321
2345678765432
3456789876543
123456787654321
234567898765432
12345678987654321
```
Any other input should give a falsy value. Of course, you do not have to handle invalid inputs, such as non-positive numbers, non-integers, or non-numbers.
As usual, this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so standard loopholes are banned, and the shortest answer in bytes wins!
  
[Answer]
# Python 2, ~~48~~ ~~47~~ 46 bytes
```
lambda s:s[~len(s)/2:]in'987654321'>s==s[::-1]
```
Test it on [Ideone](http://ideone.com/xoRXh9).
### How it works
In Python, a chained comparison returns *True* if and only if all individual comparison do the same. In this specific case, our lambda returns *True* if and only if all of the following conditions are met.
* `s[~len(s)/2:]in'987654321'`
For a string **s** of length **2n + 1**, `~len(s)/2` returns **~(2n + 1) / 2 = -(2n + 2) / 2 = -(n + 1)**, so `s[~len(s)/2:]` yields the rightmost **n + 1** characters of **s**.
Similarly, for a string **s** of length **2n**, `~len(s)/2` returns **~(2n) / 2 = -(2n + 1) / 2 = -(n + 1)** (integer division always round towards **-∞**, so `s[~len(s)/2:]` once more yields the rightmost **n + 1** characters of **s**
The comparison returns *True* if and only if the rightmost **n + 1** characters form a substring of `987654321`.
Note that if they do and **s** has **2n** characters, **s** cannot be a palindrome; the **n**th and **(n+1)**th characters from the right will be distinct, and the latter is the **n**th character from the left.
* `'987654321'>s`
This compares the strings lexicographically. Since **9** is the only Giza number that starts with **9**, all Giza numbers satisfy this comparison.
Note that comparing these strings does not form part of our decision problem; `>s` is simply three characters shorter than `and s`.
* `s==s[::-1]`
This returns *True* if and only if **s** is a palindrome.
[Answer]
# Perl, ~~39~~ ~~37~~ ~~42~~ 39 + 1 = 40 bytes
Using a new method, I managed to cut down a huge number of bytes. Run with the `-n` flag. Accepts input repeatedly at runtime, printing 0 or 1 accordingly.
I had to add 5 bytes because I realized without it, the code worked for inputs such as 1234567900987654321, which is not a Giza number. Since Giza numbers never contain the digit 0 (and all false positives by necessity would contain the digit 0), these 5 bytes account for that.
```
say!/0/*($_- s/..?/1/gr**2)=~/^(.)\1*$/
```
Explanation:
```
say!/0/*($_- s/..?/1/gr**2)=~/^(.)\1*$/  #$_ contains input by default.
   !/0/                                  #Ensure that the initial text doesn't contain the number 0
       *                                 #Since both halves of this line return either 0 or 1, multiplying them together only yields 1 if both are true (which we want).
             s/   / /gr                  #Perform a substitution regex on $_ (see below)
                                         #/g means keep replacing, /r means don't modify original string; return the result instead
               ..?                       #Replace 1 or 2 characters (2, if possible)...
                   1                     #...with the number 1
                       **2               #Square this number...
        ($_-              )              #...and subtract it from the input
                           =~            #Do a regex match on the result
                             /^      $/  #Make sure the regex matches the WHOLE string
                               (.)       #Match any character...
                                  \1*    #...followed by itself 0 or more times
say                                      #Finally, output the result of the whole line of code.
```
The purpose of the substitution regex is to construct a string of 1s whose length is half the length of the input, rounded up. Thus, an input of `12321` will produce the string `111`, which then gets squared (explanation below). Even-length inputs will produce strings that are too small to ensure the final regex is successful.
The reason this code works is because of the following:
```
        1         =         1**2
       121        =        11**2
      12321       =       111**2
     1234321      =      1111**2
    123454321     =     11111**2
   12345654321    =    111111**2
  1234567654321   =   1111111**2
 123456787654321  =  11111111**2
12345678987654321 = 111111111**2
```
We can clearly see that the number of 1's in RHS is equal to 1/2 more than half the size of LHS. (1 more if we truncate). Additionally:
567898765 - 123454321 = 444444444, which is just 4 repeating. So when we subtract our square from our number, if we get a repdigit, our original number is a Giza number.
# Old code and old method (58 + 1 = 59 bytes)
Saved 1 byte thanks to @Dada
Run with the `-n` flag, pipe text in using `echo`
```
say$_==($;=join"",/(.)/..($==y///c/2+/(.)/)-1).$=.reverse$
```
Calculates the unique giza number determined by the length and the leading integer, and sees if it matches the input.
Run as `echo -n "123454321" | perl -M5.010 -n giza.pl` 
Returns `1` if it's a Giza number, null otherwise.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~10~~ ~~7~~ 6 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
9ẆŒBḌċ
```
Generates all 45 Giza numbers numbers, then tests for membership.
[Try it online!](http://jelly.tryitonline.net/#code=OVLhuobFkkLhuIzEiw&input=&args=MTIzNDU2Nzg5ODc2NTQzMjE) or [see the generated numbers](http://jelly.tryitonline.net/#code=OVLhuobFkkLhuIxZ&input=).
### How it works
```
9ẆŒBḌċ  Main link. Argument: n
9       Set the return value to 9.
 Ẇ      Windows; yield all "substrings" of [1, ..., 9].
  ŒB    Bounce; map each [a, ..., b] to [a, ..., b, ..., a].
    Ḍ   Undecimal; convert the digit arrays to integers.
     ċ  Count the number of occurrences of n.
```
[Answer]
# JavaScript (ES6), ~~46~~ ~~45~~ ~~42~~ 41 bytes
```
f=([c,...s])=>s+s&&c-s.pop()|c-~-f(s)?0:c
```
Takes input as a string and returns a single-digit string for truthy, `0` for falsy.
The basic idea is to check for a few things:
* If the string is one char long, OR
* the first char is the same as the last char, and
* the middle section is also a Giza number, and
* the second char is one more than the first char here.
[Answer]
## Java 7, ~~128 119~~ 105 bytes
```
boolean t(long n){long a=1,b=1,c=0;for(;a<n/10;b=b*b<=n/10?b*10+1:b,c^=1)a=a*10+1;return(n-b*b)%a<1&c<1;}
```
No more strings! So, now I start by generating a `111...` number of the same length as input (`a`), and one shorter to square (`b`). Then you can subtract `b*b` from the input and check divisibility by `a`. `c` is just there to check odd/even, pay it no mind >\_>
Whitespaced:
```
boolean t(long n){
    long a=1,b=1,c=0;
    for(;a<n/10;b=b*b<=n/10?b*10+1:b,c^=1)
        a=a*10+1;
    return(n-b*b)%a<1&c<1;
}
```
### Old Method, 119 bytes
```
boolean g(char[]a){int i=1,l=a.length,b=1,d;for(;i<l;b*=i++>l/2?d==-1?1:0:d==1?1:0)d=a[i]-a[i-1];return b>0?l%2>0:0>1;}
```
Walks through the array, checking for a difference of 1 (or -1, depending on which half) between each digit. Then just checks to see the length is odd.
Whitespaced:
```
boolean g(char[]a){
    int i=1,l=a.length,b=1,d;
    for(;i<l;b*=i++>l/2?d==-1?1:0:d==1?1:0)
        d=a[i]-a[i-1];
    return b>0?l%2>0:0>1;
}
```
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), ~~9~~ 8 bytes
Truthy is **1**, falsy is **0**.
```
9LŒ€ûJ¹å
```
Uses the **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=OUzFkuKCrMO7SsK5w6U&input=MTIzMjE)
[Answer]
# Python 2, ~~77, 76, 64~~, 63 bytes
```
f=lambda s:2>len(s)or(s[0]==s[-1]==`int(s[1])-1`and f(s[1:-1]))
```
A simple recursive solution. Checks to see if the first and last digits equal each other and the second digit minus one. Then checks if the middle is also a Giza number. Returns true once it gets down to a single digit.
*One byte saved thanks to @Rod, a **ton** of bytes saved thanks to DLosc and ETHProductions!*
[Answer]
## PowerShell v3+, ~~147~~ ~~108~~ 67 bytes
```
$args[0]-in(1..9+(1..8|%{$i=$_;++$_..9|%{-join($i..$_+--$_..$i)}}))
```
Radically changed approach. Generates all possible Giza numbers, and then checks whether the input `$args[0]` is `-in` that collection. Below is how the collection of Giza numbers is formed:
```
1..9+(1..8|%{$i=$_;++$_..9|%{-join($i..$_+--$_..$i)}})
      1..8|%{                                       }  # Loop from 1 up to 8
             $i=$_;                                    # Set $i to the current number
                   ++$_..9|%{                      }   # Loop from one higher up to 9
                                   $i..$_+--$_..$i     # Build two ranges and concatenate
                                                       # E.g., 2..5 + 4..2
                             -join(               )    # Join into a single string
1..9+(                                               ) # Array concatenate with 1 to 9
```
Example runs:
```
PS C:\Tools\Scripts\golfing> 12321,5678765,121,4,123321,1232,5678,13631|%{"$_ --> "+(.\giza-numbers.ps1 "$_")}
12321 --> True
5678765 --> True
121 --> True
4 --> True
123321 --> False
1232 --> False
5678 --> False
13631 --> False
```
[Answer]
# Python 3, 65 bytes
```
lambda x:len(x)<18and x[:len(x)//2+1]in'0123456789'and x[::-1]==x
```
I'm not entirely sure, but I think this works.
[Answer]
## Python 2, ~~68~~ ~~73~~ 66 bytes
```
lambda n:n==`int('1'+len(n)/2%9*'1')**2+int(len(n)*`int(n[0])-1`)`
```
abusing the fact that `11^2=121`, `111^2=12321` and so on, I calculate this and add `1111..` enough times as offset.  
Examples:  
`23432=111^2+11111*1`  
`676=11^2+111*5`
[Answer]
## Perl, 41 bytes
40 bytes of code + `-p` flags.
```
s/(.)(?=(.))/$1-$2/ge;$_=/^(-1(?1)1|).$/
```
Outputs 1 if the input is a Giza number, nothing otherwise. Supply the input without final newline to run it :
```
echo -n '123456787654321' | perl -pe 's/(.)(?=(.))/$1-$2/ge;$_=/^(-1(?1)1|).$/'
```
**Explanations** : first, `s/(.)(?=(.))/$1-$2/ge` replace each digit `$1` (followed by `$2`) by `$1-$2`. If it's a Giza number, then each digits being one less than the next in the beginning, and one more in the end, then the string should contain only `-1` in the first part, and `1` in the second (except the last that is left unchanged). That's what the second part `/^(-1(?1)1|).$/` checks : looks for a `-1` followed by *recursion* followed by a `1`.
*-1 byte thanks to Martin Ender.*
---
My previous version 15 bytes longer (quite different so I'll let it here) :
```
echo -n '123456787654321' | perl -F -pe '$\=$_ eq reverse;$\&=$F[$_-1]+1==$F[$_]for 1..@F/2}{'
```
[Answer]
# ><> FISH ~~57~~ ~~52~~ ~~49~~ 48 bytes
```
i:1+?!vi00.;n1<
%?v0n;>~l:1-?!^2
{:<11 ^?:=@:$+=
```
Edit 1: = returns 0 or 1 if true so removed a check and used this value to increment, then it checks equality after anyway. (saved 6 bytes, lost 1 for new line).
Edit 2: 3 directional markers removed and 11 placed into gap to offset the stack to an even length to force false ( 3 bytes saved).,
Edit 3: Duplicate the length of the stack for checking MOD by 2 and len(1), this was done by putting the length on twice before but this now filled an empty space on line 2 ( 1 byte saved).
[Answer]
# C#, ~~120~~ ~~86~~ ~~108~~ ~~102~~ 92 bytes
```
x=I=>{var Z=I.Length;return Z<2?1>0:I[0]==I[Z-1]&I[1]-0==I[0]+1?x(I.Substring(1,Z-2)):0>1;};
```
Full program with some test cases:
```
class a
{
    static void Main()
    {
        Func<string, bool> x = null;
        x = I=>
        {
            var Z=I.Length;
            return Z==1?                           // length == 1?
                     1>0:                          // return true (middle of #)
                     I[0]==I[Z-1]&I[1]-0==I[0]+1?  // else start == end and the next number is 1 above the current?
                       x(I.Substring(1,Z-2)):      // recursive call on middle
                       0>1;                        // else false
        };
        Console.WriteLine("1 -> " + (x("1") == true));
        Console.WriteLine("9 -> " + (x("9") == true));
        Console.WriteLine("121 -> " + (x("121") == true));
        Console.WriteLine("12321 -> " + (x("12321") == true));
        Console.WriteLine("4567654 -> " + (x("4567654") == true));
        Console.WriteLine("12345678987654321 -> " + (x("12345678987654321") == true));
        Console.WriteLine("12 -> " + (x("12") == false));
        Console.WriteLine("1221 -> " + (x("1221") == false));
        Console.WriteLine("16436346 -> " + (x("16436346") == false));
        Console.WriteLine("123321 -> " + (x("123321") == false));
        Console.WriteLine("3454321 -> " + (x("3454321") == false));
        Console.WriteLine("13631 -> " + (x("13631") == false));
        Console.WriteLine("191 -> " + (x("13631") == false));
        Console.Read(); // For Visual Studio
    }
}
```
Hooray for single line conditionals, now beating the Java answer :)! Also got to write my first explaining comments, though it's probably self explanatory. Thanks to @Dada for finding a problem with my algorithm (was true for numbers that were mirrored like 13631). Now sub 100 since apparently checking for length%2 is redundant.
[Answer]
# Bash, 111 bytes
*UPDATE*
Note that input number normalization can probably be skipped completely, if you just add the first digit back to your generated *GIZA* number, like that:
```
01210 + 6 => 67876
```
and then just compare it with the input directly.
**Disclaimer:** this one is not really optimized, so it is more a proof of concept than a real contender
**Golfed**
```
G() { I=`sed "s/./\0-${1::1}\n/g"<<<$1|bc`;Z=`seq 0 $((${#1}/2))`;A=`rev <<<$Z`;cmp -s <(echo $I) <<<$Z${A:1}
```
**Algorithm**
Any *GIZA* number can be normalized to its canonical form, by substracting its first digit from the rest:
```
67876 - 6 => 01210
78987 - 7 => 01210
```
and there is only one canonical *GIZA* number of a particular length.
Knowing this we can easily generate a canonical *GIZA* number based on the input number length:
```
 Z=`seq 0 $((${#1}/2))`;A=`rev <<<$Z` => $Z${A:1}
```
then normalize the input number:
```
 I=`sed "s/./\0-${1::1}\n/g"<<<$1|bc`
```
and compare
```
 cmp -s <(echo $I) <<<$Z${A:1};
```
**Test**
```
for i in `seq 0 1000`; do G $i && echo $i; done
0
1
2
3
4
5
6
7
8
9    
121
232
343
454
565
676
787
898
...
G 12345678987654321 && echo "OK" || echo FALSE     
OK
G 123456789987654321 && echo "OK" || echo FALSE
FALSE
```
[Answer]
# [Actually](http://github.com/Mego/Seriously), 22 bytes
```
9uR;∙`xR;RdX+εj`M;░#íu
```
[Try it online!](http://actually.tryitonline.net/#code=OXVSO-KImWB4UjtSZFgrzrVqYE074paRI8OtdQ&input=IjEyMzIxIg)
Takes input as a quoted string (e.g. `"12321"`). Output is a positive integer for true, and `0` for false.
Explanation:
```
9uR;∙`xR;RdX+εj`M;░#íu
9uR;∙                   cartesian product of [1,2,3,4,5,6,7,8,9,10] with itself
     `xR;RdX+εj`M       for each pair:
      x                   construct the half-open (end-exclusive) range ([1, 5] -> [1, 2, 3, 4])
       R                  reverse
        ;RdX+             duplicate, reverse, remove first element, prepend ([1, 2, 3, 4] -> [1, 2, 3, 4, 3, 2, 1])
             εj           concatenate into a string
                 ;░     filter out empty strings
                   #íu  test for membership
```
[Answer]
## Haskell, 62 bytes
```
(`elem`[[j..pred i]++[i,pred i..j]|i<-['1'..'9'],j<-['1'..i]])
```
The input is taken as a string.
Creates a list of all Giza numbers an checks if the number is in it. The list is created by looping `i` through `'1'..'9'` and then `j` through `'1'..i` and creating the elements `j .. i-1 , i , i-1 .. j`.
[Answer]
# [><>](http://esolangs.org/wiki/Fish), 62 bytes
```
i:0(   ?v
v!1&!~{!<:=$:@&-1=+2=*>l!-3!1(!:?
>l!;2!n=!0?!<-1=n;
```
[Try it online!](http://fish.tryitonline.net/#code=aTowKCAgID92CnYhMSYhfnshPDo9JDpAJi0xPSsyPSo-bCEtMyExKCE6Pwo-bCE7MiFuPSEwPyE8LTE9bjs&input=MTIzNDU2Nzg5ODc2NTQzMjE)
Outputs 1 for a Giza number; 0 otherwise. Works by pushing the input into a dequeue (ok, technically a reversible stack) and repeatedly testing both ends for equality, as well as making sure they are exactly one larger than the previous value.
[Answer]
# [CJam](http://sourceforge.net/projects/cjam/), ~~20~~ 19 bytes
```
l_$_W=),\ci>_W<W%+=
```
[Test suite.](http://cjam.tryitonline.net/#code=cU4vezpMOwoKTF8kX1c9KSxcY2k-X1c8VyUrPQoKXW59Lw&input=MQoyCjMKNAo1CjYKNwo4CjkKMTIxCjIzMgozNDMKNDU0CjU2NQo2NzYKNzg3Cjg5OAoxMjMyMQoyMzQzMgozNDU0Mwo0NTY1NAo1Njc2NQo2Nzg3Ngo3ODk4Nwo3ODk5ODcKMTMxCjEyMzIzMjEKMTIzNAo0MzIxCjEyMzQzMgoyMzQzMjE)
### Explanation
The basic idea is to find the minimum and maximum digit, then create a Giza number from those and then check that it's equivalent to the input.
```
l       e# Read input.
_$      e# Get a sorted copy of the input.
_W=     e# Get its last character, i.e. the maximum digit M.
),      e# Get a string with all characters from the null byte up to M.
\c      e# Get the first character of the sorted string, i.e. the minimum
        e# character m.
i>      e# Convert to its character code and discard that many leading
        e# characters from the string we generated before. Now we've got
        e# a string with all digits from m to M, inclusive.
_W<W%+  e# Palindromise it, by appending a reversed copy without M.
=       e# Check that it's equal to the input.
```
Instead of the minimum character, we can also use the first character, for the same byte count:
```
l_:e>),1$ci>_W<W%+=
```
[Answer]
# Mathematica, ~~62~~ ~~61~~ 60 bytes
*Saved 2 bytes due to [@MartinEnder](http://ppcg.lol/users/8478).*
```
MatchQ[{a:1...,b___}/;{b}==-{a}]@*Differences@*IntegerDigits
```
Composition of functions. Takes a number as input and returns `True` or `False` as output.
[Answer]
# Retina, ~~55~~ ~~54~~ 36 bytes
Byte count assumes ISO 8859-1 encoding.
```
.
$*1:
+`^(1+:)(1\1.*)\b\1$
$2
^1+:$
```
[**Try it online**](http://retina.tryitonline.net/#code=LgokKjE6CitgXigxKzopKDFcMS4qKVxiXDEkCiQyCl4xKzok&input=MTIzNDU2Nzg5ODc2NTQzMjE)
Convert each digit to unary, separated by colons. Loop, removing matching outer digits if the next digit is one more. Match a single remaining digit.
[Answer]
# PHP, 71 bytes
```
for($t=$i=max(str_split($s=$argv[1]));$t!=$s&&--$i;)$t="$i$t$i";echo$i;
```
fetches the largest digit from input and counts down, adding the new digit to a comparison string until input and comparison string are equal - or `$i` is `0`.
prints the lowest digit for a Timmy Number, `0` else.
[Answer]
# [Pushy](https://github.com/FTcode/Pushy), ~~30~~ 15 bytes
I woke up this morning and realise I could half the length of my answer...
```
s&K-kL2/OvhXwx#
```
(non-competing as the language postdates challenge)
Input is given on the command line: `$ pushy gizas.pshy 3456543`. Outputs `1` for truthy and `0` for falsy. Here's the breakdown:
```
s                  % Split the number into its individual digits
 &K-               % Subtract all digits by the last 
    kL2/  h        % Get the halved length of the stack (+1)
        Ov X       % In stack 2, generate range (0, halved length)
            w      % Mirror the range 
             x#    % Check stack equality and output
```
The algorithm was inspired by the bash answer: first, normalize the number, (`45654 -> 01210`), then generate the normalized giza number of the same length (there is only one), and compare.
---
**Old Solution**
```
s&K-Y?kL2%?L2/:.;&OvhXx#i;;;0#
```
[Answer]
## Racket 292 bytes
```
(let*((s(number->string n))(sn string->number)(st string)(lr list-ref)(sl(string->list s))(g(λ(i)(-(sn(st(lr sl(add1 i))))
(sn(st(lr sl i)))))))(cond[(even?(string-length s))#f][(not(equal? s(list->string(reverse sl))))#f][(andmap identity
(for/list((i(floor(/(length sl)2))))(= 1(g i))))]))
```
Ungolfed: 
```
(define(f n)
  (let* ((s (number->string n))
         (sn string->number)
         (st string)
         (lr list-ref)
         (sl (string->list s))
         (g (λ (i) (- (sn(st(lr sl (add1 i))))
                      (sn(st(lr sl i)))))))
    (cond
      [(even? (string-length s))
       #f]
      [(not(equal? s (list->string (reverse sl))))
       #f]
      [else
       (andmap identity
               (for/list ((i (floor(/(length sl)2))))
                 (= 1 (g i))))]
      )))
```
Testing: 
```
(f 12321) 
(f 123321)  ; only this should be false; 
(f 9)
(f 787)
(f 67876)
(f 4567654)
(f 123454321)
(f 12345654321)
(f 1234567654321)
(f 123456787654321)
(f 12345678987654321)
```
Output: 
```
#t
#f
#t
#t
#t
#t
#t
#t
#t
#t
#t
```
[Answer]
# Java 8, 162 + 19 bytes
19 for `import java.util.*;`
```
s->{List f=new ArrayList();for(int i=0;i<9;){String l=String.valueOf(++i);for(int j=i;j>0;){f.add(l);String k=String.valueOf(--j);l=k+l+k;}}return f.contains(s);}
```
Different approach to the other Java answer, I wanted to try and use the method of creating all the possible Timmy numbers and checking to see if our string was contained in them. 
[Answer]
# Octave, 56 bytes
```
@(n)nnz(n)<2||~(abs(diff(+n))-1)&&diff(+n(1:1+end/2))==1
```
Check out all test cases [here](http://ideone.com/lPcrk1). 
This would be two less bytes in MATLAB, since `diff(n)` works for strings. In Octave, you need `diff(+n)`.
**Explanation:**
```
@(n)                  % Anonymous function taking a string `n` as argument
    nnz(n)<2          % True if there is only one element in n
            ||        % Short circuit or operator. Expression will be true if this is true
~(abs(diff(+n))-1)    % Takes the absolute value of the difference between adjacent numbers
                      % which should always be 1. Subtracts 1, to get 0
                      % and negates it to get 1 (true)
diff(+n(1:1+end/2))==1   % Checks if the difference between the first half of the numbers
                         % is 1.
                      % If either the first, or both the second and third argument is true
                      % then the function will return 1, otherwise 0. 
```
[Answer]
# Mathematica, 56 bytes
This is a little shorter:
```
MatchQ[Differences@IntegerDigits@#,{a:1...,b__}/;b==-a]&
```
[Answer]
# Java 7, ~~129 119~~ 109 bytes
```
boolean e(char[]a){int l=a[0]-1,f=0,b=a.length-1;for(;f<b&&a[f]==++l&a[f++]==a[b--];);return f==b&l==a[b]-1;}
```
### Old Recursive Method, 119
```
boolean b(char[]a){int b=a.length;return b>1&&a[0]==a[b-1]&a[0]+1==a[1]?b(java.util.Arrays.copyOfRange(a,1,b-1)):b==1;}
```
-10 bytes thanks to Geobits. We ~~are~~ were tied...
[Try it online!](https://tio.run/##ndFPb4IwGAbwu5@i8WAgCLEq0Ib1sOy8k0fCodWiuFoMVBdj/OyOsWXZlmXJw4k/eaDv@3v28izD@qjtfvNyXxvZtuRZVpZc76qujZaWaG@9k01eSP9aWUeMkPmsCOm0FLOpEjIy2m7dLqRZWTdeVj6oyUTmZSFEEJj3uyDo7mWuwrDI/KzR7tRYUgqhJqZ/3/0ru92PJ2WqNWmddN3lXFcbcujm8Fauqey2P31EPkZTRBCrX/sHz89Gq0vr9CGqTy46dmFnrKci7Y3pOHL1Uzf7Y9PIi@f7/2TnQHYBZJdANgayCZBNgSwDshzI0jnUxgLqYwk1EkOdJFArKdQLg5rhDPJegOJL0DwG1RPQPQXlGWjPIX3aA4GiMWyawKop7MpgWY7Z0s/VUa1kgFc6QIwNMOOgGv1aCFZIBzmwQRIctaDfRsQ3YwN34/B29MeBAybl@Kz016d/nXob3e5v "Java (OpenJDK 8) – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~43~~ 34 bytes
*Thanks to Jo King for -9 bytes.*
```
{!/0/==set comb $_- S:g/..?/1/²:}
```
Port of [Gabriel Benamy's Perl solution](https://codegolf.stackexchange.com/a/100075/14109).
[Try it online!](https://tio.run/##DcxBDoIwFEXRsaziSYgzKe3vbwGtLMIFEDXUiQQDTgjpplyCG6sd3jO472F@mTiuB@/itheVcG4ZPnhM4x1Ff8S1fYqy7IQUv28bop9mnBtIJUGawMbW1jAUN@AaNhExQZHWpMAVX7Blu@W2Ii96uFSdT9uQn7IQ/w "Perl 6 – Try It Online")
[Answer]
# Cjam, 35 bytes
Probably very suboptimal... I'm a little out of practice!
```
q__W%=\_,_2%@@2/)<2ew{:-}%e`,1=]:e&
```
[Try it online!](http://cjam.aditsu.net/#code=q__W%25%3D%5C_%2C_2%25%40%402%2F)%3C2ew%7B%3A-%7D%25e%60%2C1%3D%5D%3Ae%26&input=45654)
[Answer]
# Python 2, ~~50~~ ~~82~~ ~~81~~ 80 bytes
```
def f(a):b=len(a)/2+1;print(1,0)[a[:b-1]!=a[b:][::-1]or a[:b]not in'123456789']
```
Simple approach. Just splits the string in half (missing out the middle character or one after the middle character if it is of even length), reverses the second half then compares the two and compares the first half with a string of 1 to 9.
**Edit**
Reposted after constructive feedback from fellow golfers and realising and correcting my mistakes.
-1 for losing a (waste of) space
-1 for reading the question again and realising that we don't need to take 0 into account. Really must stop golfing after a long day at work.
]