Introduction to Sets problem's solution. This is the solution to a HackerRank problem. Click here to see the problem.
Code:
def average(arr):
arr_set = set(arr)
return sum(arr_set)/len(arr_set)
if __name__ == '__main__':
n = int( input() )
arr = list( map( int, input().split() ) )
result = average(arr)
print(result)
Test Input:
10
161 182 161 154 176 170 167 171 170 174
Test Output:
169.375