๐Ÿ† [M๐Ÿ’™ Challenge] Odven Number ๐Ÿ”ข | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 16

๐Ÿ† [M๐Ÿ’™ Challenge] Odven Number ๐Ÿ”ข

Monday Blue ๐Ÿ’™ Challenge Series #4 Let's play with numbers again! An "odven" number is a number that starts with an odd digit and alternating between even and odd digits subsequently. (e.g 123) ๐Ÿ’ผ TASK Write a program to accept an integer determine whether it's an odven number. If it's not, display the next odven number. ๐Ÿ”ง TEST CASE โœ… 123 โœ… 1234 โœ… 1496 โœ… 3030 โœ… 5298 โœ… 72727 โŽ 234 โ–ถ 301 โŽ 2345 โ–ถ 3010 โŽ 3239 โ–ถ 3250 โŽ 5005 โ–ถ 5010 โค BONUS Creative and clear-cut approach is encouraged. Happy Coding!!! ๐Ÿ˜๐Ÿ’ป

16th Oct 2017, 1:28 PM
Zephyr Koo
Zephyr Koo - avatar
38 Answers
9th Oct 2017, 5:23 AM
m abrate
m abrate - avatar
+ 16
* My try in Ruby: https://code.sololearn.com/cLAni25tH6nY/#rb Nice Challenge, thanks! PS: * Refactored code: added some OOP and now met new specs * Any feedback will be very appreciated! :)
9th Oct 2017, 7:17 AM
noobcรธder
noobcรธder - avatar
9th Oct 2017, 3:11 PM
David Akhihiero
David Akhihiero - avatar
+ 9
@Vengat Yup you've done a pretty good job in such a short time! Anyway please improve the algorithm to fix the bug for 3239. ๐Ÿ˜‰
9th Oct 2017, 7:16 AM
Zephyr Koo
Zephyr Koo - avatar
+ 9
Thanks everyone for your participation! I'm having a hard time to pick the best answer again as I've observed a few submissions with clean and terse code. Anyway hope you all enjoy and let's move on to the next challenge! โค https://www.sololearn.com/Discuss/790138/?ref=app
16th Oct 2017, 3:51 AM
Zephyr Koo
Zephyr Koo - avatar
+ 9
thanks @Zephyr Koo for choosing my code as best.. โœŒ๐Ÿ˜
16th Oct 2017, 4:07 AM
m abrate
m abrate - avatar
9th Oct 2017, 3:38 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 8
https://code.sololearn.com/cQ1oXNWV9EIa/?ref=app
9th Oct 2017, 10:05 AM
qwerty
qwerty - avatar
9th Oct 2017, 2:58 PM
Hiroki Masuda
Hiroki Masuda - avatar
+ 8
https://code.sololearn.com/cef5yyU2BM6R/#cpp My Solution in C++ Probably getting updated soon...
9th Oct 2017, 9:07 PM
Tim
+ 8
My answer DOES NOT try every number begin from the gaven to achive an odven.It is FAST. And it support infinite BIG number.Try something like 9999999999999999... https://code.sololearn.com/cnXk98811RBl/#cpp
9th Oct 2017, 11:13 PM
Yunfei Duan
Yunfei Duan - avatar
+ 7
@Vengat Sorry I've amended my challenge to take it to the next level! ๐Ÿ˜‰
9th Oct 2017, 4:12 AM
Zephyr Koo
Zephyr Koo - avatar
+ 7
@sayan chandra Odven number requires alternating odd and even digits. ๐Ÿ˜‰
9th Oct 2017, 5:12 AM
Zephyr Koo
Zephyr Koo - avatar
9th Oct 2017, 7:43 PM
Sayantan Sinharay
Sayantan Sinharay - avatar
+ 6
Decided I had enough of one-liners
9th Oct 2017, 3:39 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 6
@Vengat One-liner is fine as long as it's comprehensible. ๐Ÿ˜‰
9th Oct 2017, 3:53 AM
Zephyr Koo
Zephyr Koo - avatar
+ 6
@sayan Not really. I just updated the test cases with next Odven numbers only. ๐Ÿ˜‰
9th Oct 2017, 5:30 AM
Zephyr Koo
Zephyr Koo - avatar
+ 6
So Zephyr mine works?
9th Oct 2017, 5:40 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
9th Oct 2017, 4:17 PM
Christian Barraza
Christian Barraza - avatar
+ 6
Oh yeah
10th Oct 2017, 1:06 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar