how to write a program for A step Number? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

how to write a program for A step Number?

A number for which every pair of consecutive digits has a difference of one is a step number (eg. 456567). Help me generate a good program which gives us step numbers in a range!

10th Feb 2019, 1:20 PM
Usman Amin
Usman Amin - avatar
7 Answers
+ 3
Usman Amin here an algorithm that uses binary search: https://code.sololearn.com/c6w2vbHCbmT3/?ref=app and here the recursive version of it: https://code.sololearn.com/clL9jSzp1m5W/?ref=app Anna Danke für die Einleitung ;)
17th Feb 2019, 7:17 AM
Edward
Edward - avatar
+ 3
Edward for sure! but i think first place for zero will be ambiguous!
19th Feb 2019, 6:56 PM
Usman Amin
Usman Amin - avatar
+ 2
Actually this Q&A isnt the right place to put tasks. Put in your post, but i've done it. https://code.sololearn.com/cM9M34W61tT4/?ref=app
10th Feb 2019, 1:48 PM
ShortCode
+ 2
ShortCode I've changed it to question! your code is not working for me! it also gives Wrong output! input 55 output true which is false this has problem in double numbers
10th Feb 2019, 5:50 PM
Usman Amin
Usman Amin - avatar
+ 2
Great efforts All of you Nice Guys! Thanks for your time and creations!
19th Feb 2019, 3:26 AM
Usman Amin
Usman Amin - avatar
+ 1
I have written the code to check for one number. All it does is to check if every digit is one less or one more than the last. https://code.sololearn.com/cBjbx3Nc7Jsi/?ref=app
12th Feb 2019, 6:04 AM
Alexandru Turculet
Alexandru Turculet - avatar
+ 1
Usman Amin i was thinking, if we can consider zero and nine as adjacent numbers. like, is 89012 a step member as well? this would open a whole new series of possibilities...
19th Feb 2019, 5:18 AM
Edward
Edward - avatar