I have a pseudocode and I am required to implement a python code. Here is my pseudocode
find_bully_1(A):
for student in class:
if student is afraid of no one:
candidate = student
if no such candidate found:
return None
if everyone is afraid of candidate:
return candidate as bully
else:
return None
Below is what I have done, but there are bugs and it just could not output something. I was not really familiar with python though
def find_bully_1(A):
n = len(A)
candidate = 0
bully = 0
a = []
for i in range(n):
count = 0
for j in range(n):
if A[i][j] == 0:
count = count + 1
if count == n:
candidate += 1
a = [a,i]
count_scare = 0
for k in [a]:
count_scare = 0
for g in range(n):
if (zip(*A))[k][g] == 1:
count_scare += 1
if count_scare == n-candidate:
bully += 1
return bully
x = [[1,1,1,1],
[0,0,0,1],
[0,0,0,0],
[0,0,0,0]]