Link to home
Start Free TrialLog in
Avatar of TheTechGuysNYC
TheTechGuysNYC

asked on

Digit arrangement

Try this simple algorithm on for size.

Design an algorithm that, when given an arrangement of the digits 0,1,2,3,4,5,6,7,8,9, rearranges the digits so that the new arrangement represents the next larger value that can be represented by these digits (or reports that no such rearrangement exists if no rearrangement produces a larger value). Thus 5647382901 would produce 5647382910.
Avatar of TheTechGuysNYC
TheTechGuysNYC

ASKER

Hint:

A few examples to help the process...

0123456789
0123456798
0123456897
0123456879

Psuedocode is all that is needed to be correct...
SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you sure you don't mean for your examples to be like this?
0123456789
0123456798
0123456879
0123456897
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
adding 9 until the sum = 45 will get you to 123456888, which is not a rearangement