# ACM ICPC Team : HackerRank Solution in Python

*Solution in Python 3*

*Solution in Python 3*

Source Code Link:- ACM ICPC Team (github.com)

`def acmTeam(topic):`

ans = []

for i in range(n):

for j in range(i+1, n):

know=0

for a,b in zip(topic[i], topic[j]):

if a=='1' or b=='1':

know+=1

ans.append(know)

return [max(ans), ans.count(max(ans))]

# Explanation

Firstly, we will declare an empty list called ** ans, **Later on we will store the maximum number of topics known by a two-person team in it.

Then, we will use a nested for loop, the first for loop will iterate of the range of ** n **using a variable

**and the second for loop will iterate over range from**

*i***to**

*i+1***using a variable**

*n***.**

*j*`for i in range(n):`

for j in range(i+1, n):

The nested loop, in essence will form the combinations of all possible teams. If value of ** n** in a test case is 4, then the values of

**will be (0,1), (0,2), (0,3), (1,2), (1,3), (2,3) which corresponds to all the possible combinations of two-person teams that can be formed with 4 people. Note that function parameter**

*(i,j)***is a python list which is indexed from 0 thus, we iterate over the nested loop beginning from 0 itself.**

*topic*Then, we declare a variable ** know** and instantiate it to 0.

know = 0

Now, we will use another for loop and iterate over the zip of ** topic[i]** and

**using two variables**

*topic[j]***and**

*a***. The values of**

*b***and**

*a***are characters of string of binary digits which determine whether if a topic is known by a member of a two-person team.**

*b*If either the value of ** a** equals to ‘1’ or

**equals to ‘1’ we increment**

*b***by 1. This is because value of**

*know***and**

*a***determines the knowledge of a subject by the two members of the two-person team respectively. If either equals to ‘1’ then it means the two-person team knows the subject.**

*b*We represent the above logic in our code in the following way:-

`for a,b in zip(topic[i], topic[j]):`

if a=='1' or b=='1':

know+=1

After the end of the inner most for loop we append the ** know** to

**.**

*ans*`for i in range(n):`

for j in range(i+1, n):

know=0

for a,b in zip(topic[i], topic[j]):

if a=='1' or b=='1':

know+=1

ans.append(know)

At the end of the program, we return maximum value of ** ans** which corresponds to maximum number of topics that can be known by a two person-team and count of maximum value of

**in**

*ans***in the form of a list.**

*ans*

return [max(ans), ans.count(max(ans))]