Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Transforming a list of list

I have two lists :

l1=[([𝙰,𝙱],𝙰),([𝙰,𝙲],𝙲),([𝙱,𝙲],𝙱)]
l2=[[33,27],[25,35],[42,18]]

This two list must be read like this ([A, B], A) : A win in the duel with B and the score are 33 for A and 27 for B. I would like to transfer this information in a table or a matrix such that in line on has the score of each duelist against the others that is :

A = [[0,33,25],[27,0, 42],[35,18,0]]

of course this is an example. The solution must be generic. In the time I have tried to find an elegant solution, I have encoutered the following problem : how to remove Rien from all the sublist in :

l3=[[33,𝚁𝚒𝚎𝚗,25,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗],[𝚁𝚒𝚎𝚗,27,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,42,𝚁𝚒𝚎𝚗],[𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,35,𝚁𝚒𝚎𝚗,18]]

and insert the 0according to the A matrix. Thanks for your help.

Transforming a list of list

I have two lists :

l1=[([𝙰,𝙱],𝙰),([𝙰,𝙲],𝙲),([𝙱,𝙲],𝙱)]
l2=[[33,27],[25,35],[42,18]]

This two list must be read like this ([A, B], A) : A win in the duel with B and the score are 33 for A and 27 for B. I would like to transfer this information in a table or a matrix such that in line on one has the score of each duelist against the others that is :

A = [[0,33,25],[27,0, 42],[35,18,0]]

of course this is an example. The solution must be generic. In the time I have tried to find an elegant solution, I have encoutered encountered the following problem : how to remove Rien from all the sublist in :

l3=[[33,𝚁𝚒𝚎𝚗,25,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗],[𝚁𝚒𝚎𝚗,27,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,42,𝚁𝚒𝚎𝚗],[𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,𝚁𝚒𝚎𝚗,35,𝚁𝚒𝚎𝚗,18]]

and insert the 0according to the A matrix. Thanks for your help.