How to attempt?
Question :
Find The Sum of Uncommon Numbers
Given two integer arrays input 10 and input20).
extract the numbers which are present only in any one of the array (uncommon numbers).
Calculate the sum of those numbers. Lets call it sum 1 and calculate single digit sum of
sum1,
i.e keep adding the digits of sum1 until you arrive at a single digit.
Return that single digit as output.
Note:
1. Array size ranges from 1 to 10.
2.All the array elements are positive numbers.
3.Atleast one uncommon number will be present in the arrays.
Example-1
input1: { 123, 45, 7890, 67, 2, 90 }
input2: {45, 7890, 123 )
output:
67 + 2 + 90 = 159
1 + 5 + 9 => 15
1 + 5 => 6
Example-2
input1: {6, 7, 12, 70, 44}
input2: {8, 6, 70, 44}
output:
7 + 12 + 8 => 27
2 + 7 => 9
POWERED BY
Asutosh
metti
|| test
Answers
Answer:
it is quit long so I can't help it
Answer:
The given question is a problem statement that can be resolved using any programming language such as C, C++, Java, Python, etc.
Python is a programming language is an interpreted, object-oriented, high-level, dynamically semantic programming language. Python's straightforward syntax places a strong emphasis on readability, which lowers the cost of program maintenance. Python's support for modules and packages promotes the modularity and reuse of code in programs.
Here, is the solution code in Python language.
firstlist = [123, 45, 7890, 67, 2, 90]
secondlist = [45, 7890, 123]
notBoth = set(firstlist).symmetric_difference(set(secondlist))
sum1 = str(sum(notBoth))
while len(str(sum1)) > 1:
temp = 0
for i in sum1:
temp += int(i)
sum1 = str(temp)
print(sum1)
#SPJ2