Computer Science, asked by dhruvsingh3511, 5 days ago

bucketize its products. Each product has a product ID. The product ID is a numeric
An e-commerce company wishes to number. The company has to find the bucket ID from the product ID. The company needs an algorithm which takes the product ID as an input, calculates the smallest and largest permutation with the digits of the product ID then outputs the sum of these smallest
and largest permutations as the bucket ID.

Answers

Answered by raniusha01
3

Answer:

hu wife and I was not well so we are looking for a few of them are going out for good afternoon I will be a great day before yesterday I will send

Answered by shilpa85475
12

The input will be an integer- productID,  that is representing the product ID of the product.

Output

Print an integer representing the bucket ID for the given product.

Input:  

734  

Output:  

1090

The smallest permutation with digits 7.3.4 is  347.

The largest permutation with digits 7,3,4 is 743.

Their sum 347+743=1090

Explanation:

def perm(LIST):

length= len(LIST)

if length <= 1;

yield LIST

else:  

for n in the range (0, length):

    for end in perm(LIST [:n] + LIST[:n+1] ) :

    yield [LIST [n] ] +end

result=[]

for x in perm(list( input())):

temp="".join(x)

result.append(int temp))

print(max (res) +min (result))

Similar questions