Douglas Alan wrote:
> Thank you. My question wasn't intended to be Python specific, though.
> I am just curious for purely academic reasons about whether there is
> such an algorithm. All the sources I've skimmed only seem to the
> answer the question via omission. Which is kind of strange, since i
Wow, thanks everybody! There's a lot to learn for me from these examples...
Enjoy your weekend!
Florian
Florian Brucker wrote:
Hi everybody!
Given a dictionary, I want to create a clustered version of it,
collecting keys that have the same value:
>>> d = {'a':1,
Are you sure? Is this for school?
Yes, I'm pretty sure (the values of the original dict are integers), and
no, this isn't for school :) If the "We may assume ..." made you think
so, I guess that's the way everybody formulates requirements after
having read to many math papers :D
If it is of
Hi everybody!
Given a dictionary, I want to create a clustered version of it,
collecting keys that have the same value:
>>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3}
>>> cluster(d)
{1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']}
That is, generate a new dict which holds for each value of the o