We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My code seems to work perfectly well on my machine for the same arrays as used in the test cases, but on Hackerrank they return erros. Anybody faced this before?
def plusMinus(arr):
n = len(arr)
pos = 0
neg = 0
zero = 0
for i in range(0,n):
if arr[i]>0:
pos +=1
elif arr[i]<0:
neg +=1
elif arr[i]==0:
zero +=1
pos_ratio = pos/n
neg_ratio = neg/n
zero_ratio = zero/n
print('positive ratio:', f'{pos_ratio:.6f}')
print('negative ratio:', f'{neg_ratio:.6f}')
print('zeros ratio:', f'{zero_ratio:.6f}')
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Plus Minus
You are viewing a single comment's thread. Return to all comments →
My code seems to work perfectly well on my machine for the same arrays as used in the test cases, but on Hackerrank they return erros. Anybody faced this before?
def plusMinus(arr): n = len(arr) pos = 0 neg = 0 zero = 0