[Tutor] how can I use Set.interaction function on a dictionary
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Sun Apr 23 10:39:44 CEST 2006
> 1. I have a dictionary with 4 keys and some repeated
> values for each key.
>
>>>> dida
> {'NM_001033044': [32842023, 32842023, 32842023,
> 32842023, 32842023, 32842023, 32842023, 32842023,
> 32842023, 32842023, 32842023, 32842023, 32843894,
> 32843894, 32843894, 32843894, 32843894, 32843894,
> 32843894, 32843894, 32843894, 32843894, 32844846,
> 32844846, 32844846, 32844846, 32844846, 32844846,
> 32844846, 32844846, 32844846, 32844846, 32845745],
[cut]
> 1. How can I get A^B^C^D(^ = intersection) where A, B, C and D are keys
> from dida or didi.
What would be a few concrete examples of this operation? What would be a
concrete instance of this problem, and the expected result?
That is, let's call this operation "intersection()" for the moment, and
just pretend that it exists. Can you construct a simple, sample call to
this imaginary "intersection()" function? What expected value do we get
back?
Wishful thinking through examples is a good technique when one is not
quite sure how to do something yet. (Plus it will be less ambiguous than
English --- I have to admit that I do not understand the problem statement
yet.)
Also, simplify the problem a little more: doing an operation on four
elements at once seems a bit arbitrary. Rather than four, let's bring the
problem's complexity down a bit. If you had a function to do it on two
items:
A ^ B
where A and B are either from dida or didi, would this be easier for you
to consider? Would you be able to do this smaller problem? I'd recommend
tackling this first before going all out on the bigger problem.
More information about the Tutor
mailing list