• + 9 comments

    Your code look like C++, but not Pythonic. Power of Python - built-in batterys!
    Use int(bin_string, 2) to convert string of binary representation: int('101', 2)=5
    It allow use bitwise OR (very fast).
    For counting '1' in OR-result just do it:
    bin(or_rslt).count('1')
    In sum, it turns to something like this:
    Pairs_max_top_lst=
    [bin(guys_lst[i] | guys_lst[j]).count('1')
    for i in xrange(N_guys-1)
    for j in xrange(i+1,N_guys) ]
    max_top=max(pairs_max_top) max_team_num=pairs_max_top.count(max_top)