0

these are names of UFC fighters fighting this Saturday. And I want to create every possible prediction in who wins so for example from index 0, either Jan or Glover can win... etc for the rest of the list so that one of the combinations will 100% happen irl.

(Jan Vs Glover)
(Yan Vs Sandhagen)
(Islam vs Hooker)
(Li vs Khamzat)
(Volkov vs Tybura) 
(Ankalaev vs Oezdemir)  

eg: 1st combination: (Jan, Yan, Islam, Li, Volkov, Ankalaev) 2nd (Jan, Yan, Islam, Khamzat, Tybura, Ankalaev) etc...

from:

list_a = ['Jan', 'Yan', 'Islam', 'Li', 'Volkov', 'Ankalaev']
list_b = ['Glover', 'Sandhagen', 'Hooker', 'Khamzat', 'Tybura', 'Oezdemir']

2 Answers2

1

Do you need this?

list(zip(list_a, list_b))

or this?

from itertools import product
list(product(list_a,list_b))
Alexey
  • 53
  • 4
  • oh yes that helps, now i have the 2 strings in each parenthesis, now I have to do some sort of generator that picks one of the names in the parenthesis and puts every possibility in a list – Haidar Yahfoufi Oct 29 '21 at 14:45
0

I have attempted to solve this by generating all binary numbers 0-64, and using this as a Boolean map to the list of fighters.

There are definitely faster and more elegant solutions out there, but this seems intuitive.

a = ['Jan', 'Yan', 'Islam', 'Li', 'Volkov', 'Ankalaev']
b = ['Glover', 'Sandhagen', 'Hooker', 'Khamzat', 'Tybura', 'Oezdemir']
fighters = list(zip(a, b))
winners = []

for i in range(0, 2**len(a)):
  tmp = []
  map = str(format(i, '06b'))
  for j in range(0, len(a)):
    tmp.append(fighters[j][int(map[j])])
  winners.append(tmp)

print(winners)
Archie Adams
  • 779
  • 5
  • 19