Question: python programming MEDIUM-2 A small bike shop has received a large shipment of bikes from various manufacturers. The shop owner needs to sort and group




python programming
MEDIUM-2 A small bike shop has received a large shipment of bikes from various manufacturers. The shop owner needs to sort and group the bikes based on their manufacturer. Each bike has an identification number consisting of a string of digits. The bikes of the same manufacturer have the same set of digits in their identification numbers but are shuffled. All bikes from the same manufacturer form a group. For example, if there are three bikes with the identification numbers 13245,82361 and 14235 , - There are 2 groups. - First group has the bikes with identification numbers 13245 and 14235 because they are from the same manufacturer since both identification numbers have the same digits (1,2,3,4 and 5) but in a different order. - Second group has the bike with identification number 82361 because it is from the other manufacturer since it has different digits( 8 and 6) and doesn't have the digits ( 4 and 5) that are in the first group. Your task is to help the shop owner group the bikes based on the manufacturer. Given N and N space-separated bike identification numbers. Write a program to print the identification numbers of each group on a new line. The identification numbers in each group should be sorted in ascending order. In addition, the groups should be sorted in ascending order by the first identification number of each sorted group. Input The first line of input contains an integer representing The second line of input contains space-separated integers representing identification numbers. Output The output should contain the identification numbers of each group on a new line. The identification numbers in each group should be sorted in ascending order. In addition, the groups should be sorted in ascending order by the first identification number of each sorted group. Explanation For example, if the given N=9 and the identification numbers are 144112314131241616111167989 . - The identification numbers are 14,41,12314,13124,161,611, 116,7 and 989. - The identification numbers that have the same digits but in a different order are grouped together. Among the given - 14 and 41 are a group. - 12314 and 13124 are a group. - 116, 161 and 611 are a group. .7 is a group. - 989 is a group. - The identification numbers in each group have to be sorted in ascending order. - All the groups have to be sorted based on the first identificatiop 5A number of each sorted group. Then, the output should be, Sample Input 1 Sample Input 1 Sample Output 1 714116989123144116113124611 Sample Input 2 Sample Output 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
