Challenge :
Check if the given number forms a number staircase
or not
Input :
A integer (greater than 0 and not decimal). NOTE : You can take input as string , array of digits.
Output :
a truthy / falsy value depending on whether the number forms a staircase or not
Number staircase :
A number staircase is an integer that , when read from left to right :
- Starts with 1
- which may be followed by 2
- which may be followed by 3
- and so on till
n
- then the number descends starting at n - 1
- then n - 2
- then n - 3
- and so on till it reaches 1
Note :
The may be part is used to indicate that if length > is greater than 1. If it is the order must be followed as is. i.e : 12321
Example :
12321 ---> true
12345654321 ---> true
9 ---> false
1 ---> true
2 ---> false
123421 ---> false
112312318901323 ---> false
123456789101110987654321 ---> true
Note :
The input given will always be an integer greater than 0 and will not be a decimal. Your output must be a truthy or falsy
value depending on the input
Restrictions :
This is code-golf so shortest code in bytes (for each programming language ) wins.
[1,2,3,4,5,6,7,8,9,1,0,1,1,1,0,9,8,7,6,5,4,3,2,1]
for123456789101110987654321
? \$\endgroup\$