I have 2 Lists
. The first one includes all the numbers from 1 to 10.
listA={1,2,3,4,5,6,7,8,9,10}
The second includes random numbers, like this:
listB={2,10,2,5,7,15,1000,7,25,600}
I want to find an algorithm that will take any number of the second list listB
and compare it to all numbers in listA
. If the number in listB
is equal to a number in listA
, I"ll get 1 as a result. If not it will be 0. As a final result I would like to sum all equal numbers.
Here, for example we have the result 6 because we can find 2 (twice), 7 (twice), 5 and 10 in the two lists. I need a general way because my lists includes data of 10,000 numbers.
Total @ Table[Count[l2, l1[[i]]], {i, 1, Length@l2}]
$\endgroup$