1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Suppose we have a 10 digit number 2139548760 stored in a list like this [ 2, 1, 3, 9, 5, 4, 8, 7, 6, 0 ]
we can rearrange the digits to get the next highest number using those digits. This would give us this [ 2, 1, 3, 9, 5, 6, 0, 4, 7, 8 ]
We could also rearrange the digits to get the next lowest number using those digits. This would give us this [ 2, 1, 3, 9, 5, 4, 8, 7, 0, 6 ]
Write a program that reads in a 10 digit number and store the digits in a list.
Then the program asks the user to choose whether they want the next highest number or the next lowest number.
The user chooses which one they want and the program rearranges the list to produce what they want.
Finally the program prints out the 10 digit number that the user wanted.
|