⚠️Challenge: how many odious numbers smaller than 10.000 can you find⚠️ | Sololearn: Learn to code for FREE!


⚠️Challenge: how many odious numbers smaller than 10.000 can you find⚠️

odious numbers are non-negative numbers that have an odd number of ones in the binary expansion # 21 = 10101 = 3 # 50 = 110010 = 3 Challenge: how many odious numbers smaller than 10000 can you find? edit: first of all, thanks to everyone for the massive response!! And of course thanks to Sololearn for making my first post ever COTD! Now, the answer is indeed: 5000. the solution is in fact quite simple: https://code.sololearn.com/cSURNat0z4aN/#rb ------------------------------------------------- WALL OF FAME (sorry if I missed yours) ------------------------------------------------- Phython https://code.sololearn.com/cTYPIZDj3jAe C# https://code.sololearn.com/cSMFtFx0ppSE/ Java https://code.sololearn.com/cY4Q8IWoXED7/ Ruby https://code.sololearn.com/cBS3MX4AJ5AG/ (ONELINER!) C https://code.sololearn.com/csYPoI3aYW3Z#c (ASSEMBLER!) C++ https://code.sololearn.com/chPjNwhxSn9G/ Python https://code.sololearn.com/cX4YOhrrwTT4/ Python https://code.sololearn.com/cypCqoU0rX (ONELINER!) PHP https://code.sololearn.com/wtNdvjh16Ac9/ C++ https://code.sololearn.com/cAgm43t2SjAp/ PHP https://code.sololearn.com/wtHvYfDAoc1d/ C# https://code.sololearn.com/cT4V6XIp87AV/ (ONELINER!) Python https://code.sololearn.com/c5jF395sA9hZ Javascript https://code.sololearn.com/W3hRTRmTmctd/ Java https://code.sololearn.com/cliBAk1pL59h/ C# https://code.sololearn.com/cTR605gBHs6H/ (PURE MATHS!) C# https://code.sololearn.com/ccMSQT42vXXd/ Python https://code.sololearn.com/c5LP4b4H85ra/ (MATH) Web https://code.sololearn.com/WN8491v4583Q/ C++ https://code.sololearn.com/c8F2EP6kdIK0/ (FLOAT) Web https://code.sololearn.com/WN7olfJj5VH4/ C++ https://code.sololearn.com/cbU813A6sLeC/

12/11/2017 8:17:04 PM


196 Answers

New Answer


Here's onliner code 😊 Ruby is awesome 🤓 https://code.sololearn.com/cBS3MX4AJ5AG/?ref=app


I will attempt this tomorrow my friend. Edit: Here it is: https://code.sololearn.com/cWUr9TunveUH/?ref=app


print(len([j for j in range(10001) if str(bin(j)).count('1')&1])) #One liner in Python


My try in Ruby 😉 https://code.sololearn.com/caI6Dh2E7heb/?ref=app


5000 numbers are odious, which are less than 10000 https://code.sololearn.com/c7J6dwv5xs7r/?ref=app


Done : https://code.sololearn.com/cGd90xz6jql2/?ref=app Due to limitations of sololearn app , the limit can exceed a certain number . So it stops by showing : time limit exceeded EDIT : Displayed the number of numbers odius between 0 to 10000




Made this till now.. Will complete it tomorrow😴 https://code.sololearn.com/cn5oFwDUZWx4/?ref=app


my try in java https://code.sololearn.com/choS0va6Za5c/#java


Here's mine!! https://code.sololearn.com/cA4ggc0lEs1o/?ref=app


Here..... https://code.sololearn.com/caRy4hE23gyR/?ref=app


My try https://code.sololearn.com/ctCbgbltZVWv/?ref=app




5000, not 5001 (SMALLER then 10000, without 10000)


My solution in JAVA Answer : 5000 https://code.sololearn.com/cY6xgEqT8fJ6/?ref=app


Well, here we go https://code.sololearn.com/wtNdvjh16Ac9/?ref=app


@kartikey sahu Niceeeeeee one liner


One liner in c#: https://code.sololearn.com/cT4V6XIp87AV/?ref=app


My try Edit: I am adding Java version https://code.sololearn.com/cX4YOhrrwTT4/?ref=app https://code.sololearn.com/c7W665eyjYhf/?ref=app


My one liner! In Python 3 https://code.sololearn.com/cbm990nKWzAt/?ref=app