Homeworks 4, Sec 2 assigned : FRI OCT 26, due WED NOV 7.
All due times are 11:59 pm

### Part A

Write a program in which the main function calls a function with the heading def subtract(num) that takes a three digit integer num, for instance 123, and does the following

• Decomposes it into three one-character strings, a, b and c. Do this by converting num to a string s and then using s[0], s[1], and s[2] to gets the digits.
• Use the functions max(a, b, c) and min(a, b, c) that determine respectively the digits with the maximum and minimum value and assigns them to small and large in function subtract. These functions are part of the Python compiler.
• Using the program we wrote in class, determine the middle digit and assigns it to mid.
• Constructs an integer, ascend in which these digits appear in ascending order. For instance, if the original value of num was 673, the constructed integer would be 367.
• Repeats the last step but this time produces the digits in descending order. So in our example, it would produce 763. It assigns this to descend.
• Prints these two values.
• Subtracts these two numbers (descend - ascend) and returns this value to main(). So you pass an int to subtract() and return an int to main()

### Part B

• Write another program that calls function subtract defined in part A from the main function until the function returns a value that doesn't change, i.e., 495. To make things cleaner, don't print the output of subtract from part A. Try the following approach. Before the loop in main() assign 123 (or any other 3-digits number different from the one we describe next) to previous and 149 (or another 3-digit number in which all the digits are different) to present. Your program should print the value of present. Construct the while loop as follows:
```while previous != present:

.............
........ = subtract(...)

```
So you are passing an int to subtract() which in turn returns an int to main().

You will see that you get a series of integers that stops at 495.

Submit part B only, with the function written in part A. The only output you should see is what is printed in part B.