Hi Koders, today I have another daily challenge for you.
You shall ask for a list of inputs (numbers), and the program should return the number with the greatest sum of digits.
Example inputs and outputs:
magicNumber(525,245,184,114) => 184
magicNumber(111111111111,999) => 999
magicNumber(234,243) => 243
EDIT: Forgot to mention, if there are multiple numbers with the same sum of digits return the greatest one.
EDIT 2: Ask for inputs like this:
just in case u r waiting, let me say, i am trying, may be not the best but lets see
when i input no. like this it shows me error but if i set the numbers in a variable list and call that list as a input, it works
Hm, weird, but I will accept that as an answer.
this is the toughest part
I am giving my bad solution but it currently do not fulfil your duplicate number requirement, if numbers are duplicate it will give the first number in the list
I am currently working on your second part too, Will resume once electricity is back( )
there is just a small problem in that part
Oh man! , I am so dumb, i suddenly got an idea of using dictionary, , will be much more simple, just waiting for electricity, great ideas struck suddenly
Here’s my solution, tested with all three sets of provided inputs:
Proof of functionality:
Wow! Good job indeed! Could you post your solution under the details tag?
Aargh! @Kanishka_Developer was earlier! He won.
Testing of functionality:
And this are my blocks. I know, not the best way, but a way. Btw, I also did not use the Extension @Deepanshu_Arya used
Oh wow, the variable names:
Laziness rules the world
Ok, ok. This is the last one.
I love most of your variables but please avoid using variables with the same name barring the punctuation (in your case item and ITEM).
Also, maybe do this when possible?
Yes, this was a part where I saw you posting your solution, and me:
And I had no idea anymore.
I need to practice myself more
@Yoshi, I had a version without extention too. anyways keep it up
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.