- 8
Find The Sum of Uncommon Numbers Given two integer arrays input1[ ] and input2[], extract the numbers which are present only in
Find The Sum of Uncommon Numbers Given two integer arrays input1[ ] and input2[], extract the numbers which are present only in any one of the array (uncommon numbers). Calculate the sum of those numbers. Lets call it sum1 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
5 ответов
+ 1
You should really show your attempt first...
There would be many ways to acheive the same thing (especially between languages and libraries).
Here’s a quick/simple way using Python:
listOne = [123, 45, 7890, 67, 2, 90]
listTwo = [45, 7890, 123]
notBoth = set(listOne).symmetric_difference(set(listTwo))
summed = str(sum(notBoth))
while len(str(summed)) > 1:
tmp = 0
for i in summed:
tmp += int(i)
summed = str(tmp)
print(summed)
0
B_H_S_DIKO AISA H GYAN MAT PELO YHA FALTU KA MKL, 1 SAAL PHLE KA QUESTION MUJHE JHAMT MATLAB NI AB ISKE SOLUTION SE,AB BAR BAR LIKE OR ANSWER DEKE ISKA MUJHE NOTIFICATION MT BHJO,OR MKL TU ITNA HI GYANI H TO JAKE APNA PDH YHA KYA BAKCHOMDI KRRA KI IF HOMEWORK THEN DONE URSELF,RAMNDI ADMI KHUD HI KRNA HOTA TO YHA Q POST KRTA MAI CHUMTTAD.
0
Find The Sum of Uncommon Numbers
Given two integer arrays input[] and input2[1
extract the numbers which are present only in any one of the array (uncommon numbers).
Calculate the sum of those numbers. Lets call it sum1 and calculate single digit sum of sum 1,
ie 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 Rightarrow6
Example-2
input1: \{6, 7, 12, 70, 44\} input2: \{8, 6, 70, 44\}
output: 7 + 12 + 8 =>27 2 + 7 =>9
0
Find Key:
You are provided with 3 numbers: input1, input2 and input3.
Each of these are four digit numbers within the range >=1000 and <=9999.
Le 1000 <= input1 <= 9999 1000 <= input2 <= 9999
1000 <= input3 <= 9999
প্র
}
You are expected to find the Key using the below formula
Key = [LARGEST digit in the thousands place of all three numbers - smallest digit in the thousands place of all three numbers] [LARGEST digit in the hundreds place of all three numbers- smallest digit in the hundreds place of all three numbers] [LARGEST digit in the tens place of all three numbers - smallest digit in the tens place of all three numbers] [LARGEST digit in the units place of all three numbers - smallest digit in the units place of all three numbers]
For e..g. if input1 = 3521, input2=2452, input3=1352, then Key = [3-1] [5-3] [5-2] [2-1] = 2231
Assuming that the 3 numbers are passed to the given function, Complete the function to find and return the
- 4
if homeWork:
self.toDo()
return