Skip to content
Advertisement

comparing a number of lists in pairs

I have problem with 4 list each one got 4 number:

P1= [3,1,3,4]

P2= [5,4,3,7]

P3= [7,4,8,1]

P4= [10,3,2,1]

I need to get the biggest number in combinational way like: Pair of 2: p1p2, p1p3, p1p4, p2p3, p2p4, p3p4

Pairs of 3: p1p2p3, p1p2p4, p1p3p4, p2p3p4

Pairs of 4: p1p2p3p4

The result for:

p1p2= [5,4,3,7]

p1p3= [7,4,8,4]

p1p4= [10,3,3,4] ……

I wrote this program and I store it in a matrix instead of a list. ‘ n= int (input(“Enter the matrix size:”))

JavaScript

Is there a better way to do it?

Advertisement

Answer

There is at least one more way. Wait for more elegant solutions.

JavaScript

Gives the following output.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement