+ 50

[M💙 Challenge] Staircase Number

Monday Blue 💙 Challenge Series #11 Let's identify the pattern this week! This time we will need to determine whether the user provided number is a upward/downward staircase number or not. 💼 TASK Write a program to accept an integer and output whether it's an upward/downward staircase number and print "Not staircase number" if it's not the case. A staircase number have the following pattern:- ✔️ Compose of at least 2 distinct digits (0-9) ✔️ Same digit must be grouped together and occur at least twice Explanation: We need different digit to build the staircase step and if we plot the number as the y-value, we get a flat line with two or more occurences. So by connecting the lines we will get a staircase-like graph. ✔️ Upward if the unique digits are incerasing left-to-right ✔️ Downward if the unique digits are decreasing left-to-right Explanation: I believe this one is pretty self-descriptive. 😉 🔧 TEST CASE 11122333 "Upward staircase number" 11337788 "Upward staircase number" 33221100 "Downward staircase number" 9911 "Downward staircase number" 8080 "Not staircase number" 1234567 "Not staircase number" ❤ BONUS Clear-cut and optimized approach is encouraged. 👍 SPECIAL MENTION (RegEx submissions) https://code.sololearn.com/W23lPuTDqEP7/?ref=app https://code.sololearn.com/cvL9enWmJdFg/?ref=app https://code.sololearn.com/cRET7qJNZvt9/?ref=app https://code.sololearn.com/cf6oJ7dGwStu/?ref=app https://code.sololearn.com/cXqeHbpo6OMW/?ref=app https://code.sololearn.com/cJTYfsYAEQSE/?ref=app Happy Coding!!! 😁💻

4th Dec 2017, 2:53 PM
Zephyr Koo
Zephyr Koo - avatar
76 ответов
27th Nov 2017, 10:15 PM
VcC
VcC - avatar
+ 21
https://code.sololearn.com/c16jy7ptDo53/?ref=app
27th Nov 2017, 5:12 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
27th Nov 2017, 10:04 AM
LukArToDo
LukArToDo - avatar
+ 17
Thanks everyone for your participation! Apologize for the late review this time as I'm really busy recently. I've noticed some interesting application of RegEx and I'm planning to promote RegEx submissions at the SPECIAL MENTION section above. In addition, I would appreciate if you can place a comment to explain how your RegEx works as well. There's no doubt Python produce elegant solutions as always but personally I find Yash Thatte's solution easiest to follow. 😉 I hope you all enjoy and let's move on to the next challenge! ❤ https://www.sololearn.com/Discuss/902040/?ref=app
4th Dec 2017, 2:47 PM
Zephyr Koo
Zephyr Koo - avatar
+ 15
Yup in this case we only accept strictly upward/downward pattern. Thanks everyone for your interest and help for the clarification! 😄
27th Nov 2017, 5:42 AM
Zephyr Koo
Zephyr Koo - avatar
+ 13
@blackcat1111 Thank you! 😄 No worry please take your time as I'll select the best answer every Monday so that means you got a whole week for it, enjoy~
27th Nov 2017, 5:06 AM
Zephyr Koo
Zephyr Koo - avatar
+ 12
@Kinshuk Yes! 6677 is an upward staircase number.
27th Nov 2017, 5:21 AM
Zephyr Koo
Zephyr Koo - avatar
+ 12
I edited code and it works now! Didn't see some rules 😂😂
27th Nov 2017, 5:22 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 12
@Pegasus Well done! 👍 Suddenly I start to miss the speedy submission by Sir Krishna. 😂
27th Nov 2017, 5:26 AM
Zephyr Koo
Zephyr Koo - avatar
+ 12
@swim I couldn't agree more but I believe those who's already fluent in Python will appreciate its beauty and straight-forward compared to C# or Java. 😄
5th Dec 2017, 12:34 AM
Zephyr Koo
Zephyr Koo - avatar
+ 11
Apologize, I mean staircase instead of ladder, silly me!!! 😂
27th Nov 2017, 5:17 AM
Zephyr Koo
Zephyr Koo - avatar
+ 11
Here! It's done. I haven't checked it extensively, though... https://code.sololearn.com/cmE2aV6ohwOb/?ref=app
27th Nov 2017, 5:27 AM
blackcat1111
blackcat1111 - avatar
+ 10
https://code.sololearn.com/cZHqRVLoT4WX/?ref=app
28th Nov 2017, 10:55 AM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
+ 9
My try...made provision for "defective" staircase numbers https://code.sololearn.com/cP6V5vYt5E58/?ref=app
27th Nov 2017, 8:22 AM
David Akhihiero
David Akhihiero - avatar
+ 9
@Kinshuk Vasisht You need at least 2 distinct digits to be a staircase number. Think of graphs. 😉
27th Nov 2017, 1:08 PM
blackcat1111
blackcat1111 - avatar
+ 8
@Yash Thatte Or you need atleast 2 steps to make a staircase, right?
27th Nov 2017, 1:07 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 7
What would be the output for 113322? It satisfies the conditions for a ladder number, but it is neither upward nor downward.
27th Nov 2017, 5:28 AM
Cristian Stollberg
Cristian Stollberg - avatar
+ 7
My try : Already optimized for defective numbers. https://code.sololearn.com/cChavbUCeGuI/?ref=app
27th Nov 2017, 6:20 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 6
heres my "" FUNCTIONAL ONE - LINER ""//very optimized ## default EVERY POSSIBLE INPUT included https://code.sololearn.com/cLbwE0pB4hx0/?ref=app
27th Nov 2017, 2:32 PM
sayan chandra
sayan chandra - avatar
+ 5
Is 6677 a staircase number?
27th Nov 2017, 5:18 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar