Python Program to Print All Distinct Uncommon Digits Present in Two Given Numbers. Given two positive integers A and B, the task is to print the distinct digits in descending order, which are not common in the two numbers.
Given two positive integers A and B, the task is to print the distinct digits in descending order, which are not common in the two numbers. Examples:
Input:_ A = 378212, B = 78124590_
Output:_ 9 5 4 3 0_
Explanation:_ All distinct digits present in the two numbers are {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. The digits {1, 2, 6, 7} are common in both numbers._
_Input: _A = 100, B = 273
Output:_ 7 3 2 1 0_
Explanation:_ All distinct digits present in the two numbers are {0, 1, 2, 3, 7}. The digits {0, 1, 2, 3, 7} are common in both numbers._
*Approach: *The problem can be solved using sets, and lists in python. Follow the steps below to solve the problem:
Python Sorting Lists — list.sort() vs sorted(list). The 2 common ways to sort a list in Python are inputList.sort() or sorted(inputList). Well, inputList.sort()sorts the list in place, in other words, you loose the original list because it will be mutated to contain the new sorted list.
Python list sort() function sorts the list ascending by default. The sort() method sorts the items of a given list in the specific order.
Guide to Python Programming Language
Python Sets Tutorial explains what exactly Sets is with an example. Python Sets Tutorial | Sets in Python | Python Sets | Python Programming
A set is a collection which is unordered and unindexed. In Python, sets are written with curly brackets.