# Goodness Giza Golf!

A "Giza number", also colloquially known as a Timmy Number is any number where the digits represent a pyramid (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. 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 , so standard loopholes are banned, and the shortest answer in bytes wins!

• what about 0? is that a thruthy? Nov 16, 2016 at 16:48
• @tuskiomi Technically, no, but it's irrelevant because you do not have to handle non-positive numbers. Nov 16, 2016 at 16:49
• The reason I ask is because if it is a giza number, then numbers like 1210, 123210, etc would also be truthy. Nov 16, 2016 at 16:50
• @tuskiomi Neither of those are palindromic or have an odd number of digits. Unless you're counting a leading 0 but that makes everything way more complicated. Nov 16, 2016 at 16:56
• @nedla2004 I think leading 0's makes input formats more complicated. To keep everything nice and simple, we'll say you can assume that inputs will not contain leading 0's. Nov 17, 2016 at 20:44

## R, 100 bytes

l=length(x<-el(strsplit(scan(,""),"")));all(x==rev(x))&all(diff(as.numeric(x[1:((l+1)/2)]))==1)&l%%2


Unfortunately, the last Giza number (12345678987654321) is too large to be represented using R's 32-bit integers. Consequently we need to treat input as a string which makes this program slightly longer and we can't effectively rely on calculations.

1. Read input as string and split into character vector: x<-el(strsplit(scan(,""),""))
2. Calculate length: l=length(x)
3. Check if x is equal to itself revered: all(x==rev(x))
4. and if the difference between the numbers 1...middle are all equal to one: &all(diff(as.numeric(x[1:((l+1)/2)]))==1)
5. and if number of characters is odd: &l%%2

g[a,b]=0>1
g(a:b:c)=a==last c&&b==succ a&&g(b:init c)
g _=1>0


# VBA, 175 bytes

Function e(s) As Boolean
Dim f As Long
For i=1 To Int(Len(s)/2)+1
x=Mid(s,i,1)
If f<>0 And ((f+1)<>x) Or (x<>Mid(s,Len(s)-i+1,1)) Then Exit Function
f=x
Next
e=1
End Function

• You do not need to declare the types of your variables, meaning that you can drop the as boolean, and dim f as long, and further reduce this solution down to Sub e(s):For i=1To Int(Len(s)/2)+1:x=Mid(s,i,1):If f<>0 And ((f+1)<>x)Or(x<>Mid(s,Len(s)-i+1,1)) Then d=1:Exit For:f=x:Next:Debug.?0 ^ d:End Sub Jun 5, 2017 at 21:09