Today’s daily challenge is to ask for a 3-digit number and return the greatest number that can be formed using the same digits.
greatest(128) => 821
greatest(503) => 530
greatest(170) => 710
greatest(888) => 888
greatest(910) => 910
Have fun!
Today’s daily challenge is to ask for a 3-digit number and return the greatest number that can be formed using the same digits.
greatest(128) => 821
greatest(503) => 530
greatest(170) => 710
greatest(888) => 888
greatest(910) => 910
Have fun!
What if the given number is already the greatest number? should the program return the same number again or say: “the given number is already the greatest, there is no greater number”
Yosh
Return the greatest number, will add a sample to my original post.
I thought why to reinvent the wheel when we have a bubble sorting procedure. So i took the whole number and i split all digits and place them in a list. Then the bubble sorting procedure did the job. It works with more than 3 digits.
Very impressive, good job! Would be nice to see the number returned instead of the sorted list, but amazing!
Great work! ![]()
Yosh
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.