The things we share

The intersection of two lists are the elements in the list that are common to both list. Given the following lists how many elements are common to both lists?

Details and Assumptions

There is no double counting.

Don't use a library function.


The answer is 51.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Bill Bell
Jul 31, 2015
1
2
3
List_1=set([94, 18, 85, 48, 92, 31, 74, 83, 11, 87, 16, 15, 74, 88, 50, 62, 60, 85, 38, 84, 16, 86, 91, 99, 36, 4, 9, 58, 69, 75, 71, 20, 28, 84, 6, 68, 52, 8, 5, 5, 63, 35, 85, 65, 34, 44, 72, 65, 68, 27, 30, 78, 38, 41, 27, 61, 59, 79, 14, 97, 21, 21, 21, 29, 35, 58, 17, 29, 4, 29, 88, 95, 36, 50, 80, 56, 65, 55, 38, 41, 3, 64, 73, 84, 51, 55, 54, 43, 22, 94, 64, 32, 93, 76, 86, 79, 12, 11, 21, 66])
List_2=set([53, 22, 16, 92, 24, 85, 28, 91, 80, 35, 34, 77, 65, 25, 51, 99, 76, 17, 49, 6, 82, 75, 25, 66, 100, 31, 98, 3, 15, 69, 36, 38, 63, 48, 87, 50, 46, 79, 42, 63, 88, 72, 81, 20, 9, 68, 90, 67, 9, 77, 38, 60, 94, 30, 73, 91, 23, 89, 28, 37, 36, 6, 51, 77, 4, 71, 97, 48, 60, 8, 19, 33, 84, 84, 62, 59, 81, 13, 3, 25, 67, 25, 45, 44, 67, 25, 4, 58, 100, 49, 60, 53, 53, 22, 14, 6, 54, 93, 27, 70, 52, 54, 76, 62])
print len(List_1.intersection(List_2))

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...