Neural Sync Active
jan-2026-python-week-7-collections-3
Registry Synced
jan-2026-python-week-7-collections-3
559 words
3 min read
Collections 3
Course: Jan 2026 - Python
Collections 3
Submission deadline has passed for this assignment
Due Apr 01, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
3/3 Passed
Submitted on Apr 01, 2026 at 3:50 AM IST
Private Tests
2/2 Passed
Submitted on Apr 01, 2026 at 3:50 AM IST
**Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.
Number of unique common digits between two integers**
Given two integers, return the number of unique digits that are common in both numbers.
Eg, 287498,295424 - 2, 4 and 9 are common to both nums so answer is 3
Template Code(Click to Expand)
def number_of_unique_common_digits(n1: int, n2: int) -> int: ''' Given two integers, return the number of unique digits that are common in both numbers. Eg, 287498,295424 - 2, 4 and 9 are common to both nums so answer is 3 Arguments: n1: int - the first number n2: int - the second number Return: int - the number of unique common digits. ''' ...
NOTE: You can use the below tools for working out and debugging. Click to open them in new tab.
Public Tests ( 3/3 )
Case 1
Input:
textis_equal(number_of_unique_common_digits(12345, 54321), 5)
Case 1
Expected Output:
text5
Case 1
Actual Output:
text5
Case 2
Input:
textis_equal(number_of_unique_common_digits(287498, 295424), 3)
Case 2
Expected Output:
text3
Case 2
Actual Output:
text3
Case 3
Input:
textis_equal(number_of_unique_common_digits(67890, 9876), 4)
Case 3
Expected Output:
text4
Case 3
Actual Output:
text4
Private Tests ( 2/2 )
Case 1
Input:
textis_equal( number_of_unique_common_digits(98765, 56789), 5 ) is_equal( number_of_unique_common_digits(42245, 49860), 1 ) is_equal( number_of_unique_common_digits(1234567890, 9876543210), 10 )
Case 1
Expected Output:
text5 1 10
Case 1
Actual Output:
text5 1 10
Case 2
Input:
textis_equal( number_of_unique_common_digits(1234567890, 9876543210), 10 ) is_equal( number_of_unique_common_digits(1234567890, 1111155555), 2 )
Case 2
Expected Output:
text10 2
Case 2
Actual Output:
text10 2
💻 IITM Official Solution
pythondef number_of_unique_common_digits(n1: int, n2: int) -> int: ''' Given two integers, return the number of unique digits that are common in both numbers. Eg, 287498,295424 - 2, 4 and 9 are common to both nums so answer is 3 Arguments: n1: int - the first number n2: int - the second number Return: int - the number of unique common digits. ''' return len(set(str(n1)) & set(str(n2)))
💻 My Submitted Code
pythondef number_of_unique_common_digits(n1: int, n2: int) -> int: # 1. Convert integers to strings, then to sets to get unique digits set1 = set(str(n1)) set2 = set(str(n2)) # 2. Use the set intersection operator (&) to find common digits common_digits = set1 & set2 # 3. Return the count return len(common_digits)