← Back to challenges

Slidey Numbers

JavaScriptHardnumbersvalidation

Instructions

A number is considered slidey if for every digit in the number, the next digit from that has an absolute difference of one. Check the examples below.

Examples

isSlidey(123454321) ➞ true

isSlidey(54345) ➞ true

isSlidey(987654321) ➞ true

isSlidey(1123) ➞ false

isSlidey(1357) ➞ false

Notes

  • A number cannot slide properly if there is a "flat surface" (example #4), or has gaps (example #5).
  • All single digit numbers can be considered slidey numbers!
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Split a String Based on Vowels and Consonants