# Daily Challenge #64

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
``````

As always,

Have fun!

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:

3 Likes

just in case u r waiting, let me say, i am trying, may be not the best but lets see

1 Like

Canโt understand

1 Like

Argh, my mistake, sorry.

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

1 Like

Hm, weird, but I will accept that as an answer.

2 Likes

just this part left

2 Likes

this is the toughest part

1 Like

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

Edit
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

3 Likes

Hereโs my solution, tested with all three sets of provided inputs:

Solution

Proof of functionality:

7 Likes

Wow! Good job indeed! Could you post your solution under the details tag?

2 Likes

Aargh! @Kanishka_Developer was earlier! He won.

Testing of functionality:

Solution

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

2 Likes

Oh wow, the variable names:

• blabla
• idkidk
• bruhbruh

2 Likes

Laziness rules the world

Ok, ok. This is the last one.

2 Likes

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?

2 Likes

Yes, this was a part where I saw you posting your solution, and me:

And I had no idea anymore.

2 Likes

Congrats @Kanishka_Developer
I need to practice myself more

@Yoshi, I had a version without extention too. anyways keep it up

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.